Python 3.11 Performance Benchmarks Are Looking Fantastic
phoronix.com
phoronix.com
https://mail.python.org/archives/list/python-dev@python.org/...
It sometimes boggles my mind how python is considered the quick and easy way for startups, while at the same time doing trivial things become such a hurdle.
This is probably risky in production anyway, because the load balancer (typically) has no insight into these background tasks and will happily kill a process/pod/etc that is running a background process. You should probably dispatch the workload to an external task runner (e.g., Lambda or a Kubernetes Job or similar) unless you really don't care if the background task gets killed mid-flight. (I've had a few dev teams ignore these warnings and then blame infrastructure when their background jobs got killed mid-flight occasionally).
But this single java app on some EC2 instance could do what you need 10 "apps" and possibly a complicated k8s deployment to handle with python. Some just because the raw performance of python is far worse, but most of it because of cases like this, where simple things can't be shared. So lots of unnecessary complexity compared to "old and verbose" java.
Another example is prometheus metrics. The current app I'm working on doesn't have a webserver. Which makes it really awkward in python to add prometheus. Since adding an endpoint to my app creates a new process and needs to be deployed almost as a sidecart, there is no smooth way to actually get the metrics from my main app to the endpoint that can be scraped since they don't share the same process.
And the HN discussion: https://news.ycombinator.com/item?id=31348097
Note that Sam's no-GIL changes are not only about the removal of the GIL (although that was the main goal). There are a number of other unrelated improvements to make it faster. And as far as I know, most of those unrelated improvements have gotten into CPython now.
It seems like the core team doesn't share my sense that nogil is the single most important thing that Python needs to do in a world of many-core processors. If nogil is now blocked because it's deemed an unacceptable performance hit vs 3.11, I'll be very, very disappointed.
So Sam came up with a way to ensure that (on balance, if not in every example), we could have same-or-better performance and no GIL. Awesome!
But now we're getting the performance boosts without the GIL removal, and so in the next release, the GIL removal will cause a performance regression unless we can somehow find more performance boosts. It feels like this could just happen forever.
eg. Unix had processes from day 1, but threads were added (with significant effort) because threads are a better abstraction for addressing lot of problems. Especially so when your CPU has lots of cores.
The work to make multiprocessing better is certainly useful, and valuable, but it's still a work-around.
I'm not worried about a lack of single thread performance increases for some time.
I'm particularly happy to see the django_template test showing so much improvement. The implementation of Django templates has been a hot topic for speed improvements for along time (and why many people jump to Jinja). Its a good example of how "complex" python will be improved by these optimisations.
Two interesting ones to compare are pickle_pure_python and json_loads (both doing (de)serialisation activities), the former shows a large improvement, the latter much less so. Again it's showing how the improvements are coming to complex pure python code, json.load is mostly c whereas the pickle_pure_python test is run against the pure python Pickle implementation.
It would be interesting to see a benchmark based on the Django test suite, that would probably be quite indicative of the impairments we can expect in real world web server Python.
If you mean "what language is most likely to be around in 2100 AD", realistically we'll have C for as long as we'll have computers.
:)
Then again, if we're comparing it to Perl 6/Raku...
Note that Erlang has a two year head start on perl (and 5 on python), and Elixir has a hard Erlang dependency.
C is half-way to 100: an amazing fact in the rapidly-changing world of technology. Of all these, Perl seems to have suffered the biggest loss of popularity so far, while Erlang has the least popularity to lose.
I'd be somewhat surprised if any of these are still in common use in 2072, but OTOH, I'd also be surprised if any of them were completely unused, with the possible exception of Perl.
[1] https://docs.python.org/3.11/whatsnew/3.11.html#pep-659-spec... [2] https://docs.python.org/3/library/typing.html
https://norvig.com/python-lisp.html
Yeah, I know, at least my UNIX scripting gets a bit of performance boost.
In the past, I've seen quite a few attempts at bolting on simple template JITs onto the cPython interpreter loop[2], with lacklustre results. They'll eventually need a JIT, once all the easy wins in runtime perf have been exhausted.
OTOH, I'm glad that runtime performance is finally getting the attention it deserves from the cPython core devs. This wasn't the case, just a few years ago.
[1]: https://peps.python.org/pep-0659/ [2]: https://github.com/python/cpython/blob/main/Python/ceval.c
How soon is "eventually"? :-)
Python is 31 years old at this point, and incredibly popular. If JIT hasn't happened yet, what eventuality will finally make it happen?
For comparison, Javascript had incredibly mature JIT implementations by the time it reached its 15th year of existence.
https://lukasz.langa.pl/5d044f91-49c1-4170-aed1-62b6763e6ad0...
Edit: And to be fair, you can do "true" concurrency in Python you just have to eject to Multi-processing (with the tradeoffs that implies), so I didn't want to assume the comment was about GIL removal.
There's a link to his design overview document in the thread.
Thanks for remind me I need to install an ad blocker. Seriously, I counted ten banners for the whole article.
Alternatively a tool like pyenv makes this much easier.
>>> Install dependencies with apt (a few popular pages on google for this).
I don't know what this means :) So let's go to step 2:
>>> Download tarball.
Me tries this:
wget 'https://www.python.org/ftp/python/3.11.0/Python-3.11.0a1.tgz'
>>> Configure.What does this mean?
>>> make altinstall
I guess I somehow need to untar the tar thing first?
Me tries this:
tar -xf Python-3.11.0a1.tgz
Hurray, I have a directory :)Let's cd into it:
cd Python-3.11.0a1
And now the make altinstall? make altinstall
Gives me: bash: make: command not found
Hm... apt install make
make altinstall
Gives me: make: *** No rule to make target 'altinstall'. Stop.
Hm... yeah, looks like it is beyond my paygrade.> What does this mean?
It means to run the “./configure” script first, which is normally present in the unpacked tar file. Also, on Debian, to compile programs, you usually first have to install the “build-essential” package.
> I don't know what this means :) So let's go to step 2:
`apt-get build-dep python3`
pyenv install 3.11.0b3I also using Debian 11, and this is how I always install Python from source:
wget https://www.python.org/ftp/python/3.11.0/Python-3.11.0b3.tgz
tar xvzf Python-3.11.0b3.tgz
cd Python-3.11.0b3.tgz
sudo apt install libssl-dev zlib1g-dev libbz2-dev liblzma-dev libffi-dev tcl-dev libgdbm-dev libsqlite3-dev libreadline-dev tk tk-dev libmpdec-dev
./configure --enable-loadable-sqlite-extensions --enable-shared --with-lto --enable-optimizations --with-system-expat --with-system-ffi --with-computed-gotos --with-system-libmpdec --enable-ipv6 CC=x86_64-linux-gnu-gcc
make
sudo make altinstallpython3.11: error while loading shared libraries: libpython3.11.so.1.0: cannot open shared object file: No such file or directory