3 ms·
Is it still true that PyPy is both faster and slower than CPython - faster when restricted to pure Python but slower than CPython using C extensions?
by visarga 6y ago
Is it still true that PyPy is both faster and slower than CPython - faster when restricted to pure Python but slower than CPython using C extensions?
- moonchild 6y agoI've never heard of that. What I have heard, though, is that string operations are more expensive in pypy than cpython. Regardless, performance gains and regressions are unlikely to generalize; what's true for someone else's project may not be true for yours. If you're concerned about performance, I recommend benchmarking your own codebase.
- maxbond 6y agoThe PyPy website suggests this is the case. https://www.pypy.org/features.html https://www.pypy.org/features.html > Our main executable comes with a Just-in-Time compiler. It is really fast in running most benchmarks—including very large and complicated Python applications, not just 10-liners. > There are two cases that you should be aware where PyPy will not be able to speed up your code: > Short-running processes: if it doesn't run for at least a few seconds, then the JIT compiler won't have enough time to warm up. > If all the time is spent in run-time libraries (i.e. in C functions), and not actually running Python code, the JIT compiler will not help.
- moonchild 6y agoDoes it? It looks to me like it indicates performance will be the same when calling c functions.
- gridlockd 6y agoIt depends on how the C functions are called. CPython extension modules either don't work or have high overhead. CFFI-based modules should work without a big penalty, but these are generally slower than extension modules.
- rincewind 6y agoIt's true. Source: I benchmarked some PyGame pixel pushing. HPy might alleviate that in the future, but C extensions need to switch to HPy for that.
- globular-toast 6y agoIt depends on the code. You don't get speed for free by using C extensions with CPython. You have to write code specifically for that extension. To get significant speed benefits from numpy, for example, you need specific knowledge of numpy and the code produced will be completely different from regular Python. Pypy, on the other hand, is essentially a free speed boost when you have standard python code.