163 points · by mmastrac · 9y ago · 51 comments
One thing to keep in mind is that python 3 is still considerably slower than python 2 (edit) in some areas such as startup times while it has gotten faster in most other benchmarks.
$ echo exit | time python2
gives an average time of 0.015s on my laptop, and $ echo exit | time python3
works out to about 0.039s. If you're spamming hundreds of processes from a looping shell script, the Python 3 overhead would probably start to grate. For anything manually launched, 40 milliseconds is still substantially close to instant.> One thing to keep in mind is that python 3 is still considerably slower than python 2.
IIRC this statement started to shift ~3.4. There are still areas where 2.7 is faster, but it is more of a gray area than black and white like it used to be.
Hope 3.7 finally puts it on par (or faster) than 2.7, but we've decided to migrate with 3.6 anyway. Don't take me wrong, I like having finally put 2.x behind, but it still bothers me a bit. Maybe we just have to get used to optimizing the "3.x series".
* this has been measured without startup time, just function calls, with horrible datetime.datetime.now() timings and %timeit magic-keyword from IPython -- always consistent.
You have wrong information.
It would be very hard for someone to say "python 3 is considerably slower". Startup is significantly slower, yes, but that's about it.
The video quite definitely states otherwise for most benchmarks. Only a few benches still show regressions over P2, and according to Victor they're unlikely to affect the vast majority of systems.
I don't really remember all that clearly, but my recollection is that numerous caveats were made fairly clear (like the new IO not being optimized and so on). I guess something needed to go out the door but I wonder if the biggest mistake was calling that release the 3.0 release (rather than something that would have better tempered naive expectations).
> - Bad support of the Python C API: PyPy was written from scratch and uses different memory structures for objects. The cpyext module emulates the Python C API but it’s slow.
> - New features are first developed in CPython. In january 2016, PyPy only supports Python 2.7 and 3.2, whereas CPython is at the version 3.5. It’s hard to have a single code base for Python 2.7 and 3.2, Python 3.3 reintroduced u'...' syntax for example.
> - Not all modules are compatible with PyPy: see PyPy Compatibility Wiki. For example, numpy is not compatible with PyPy, but there is a project under development: pypy/numy. PyGTK, PyQt, PySide and wxPython libraries are not compatible with PyPy; these libraries heavily depend on the Python C API. GUI applications (ex: gajim, meld) using these libraries don’t work on PyPy :-( Hopefully, a lot of popular modules are compatible with PyPy (ex: Django, Twisted).
> - PyPy is slower than CPython on some use cases. Django: “PyPy runs the templating engine faster than CPython, but so far DB access is slower for some drivers.”
So one could argue that pypy is just as much optimisation by "rewriting it in C".