wp1 icon indicating copy to clipboard operation
wp1 copied to clipboard

Update to Python 3.14

Open audiodude opened this issue 4 months ago • 5 comments

Python 3.14 has few if any breaking changes and potentially offers up to 30% performance increase.

We should upgrade when we get a chance. It should just be a matter of bumping the versions in the Docker images and double checking that tests pass, and smoke testing the website.

audiodude avatar Sep 09 '25 15:09 audiodude

The "up to 30% performance increase" is only opt-in for now, decided at interpreter compilation time. I doubt the Python interpreter we will use for WP1 will be compiled with the corresponding flag.

Upgrading to 3.14 is still necessary and useful for maintenance.

benoit74 avatar Sep 11 '25 06:09 benoit74

Well we control which Python image we build from: https://github.com/openzim/wp1/blob/main/docker/web/Dockerfile

So maybe we can use one that has the flag flipped on?

audiodude avatar Sep 11 '25 11:09 audiodude

@benoit74 @rgaudin Shall we proceed with this upgrade? Do you have any hints as to what flags I need to enable on Python to get the performance increase? Is there a prebuilt image that I can base on?

audiodude avatar Oct 03 '25 15:10 audiodude

I would recommend to wait for Python 3.14 to reach final release (in four days) but other than that, it is mandatory to upgrade to 3.14 indeed.

I would not mind at all about finding the right flags / image to get the performance increase. It seems risky both in terms of risk of bugs impossible to understand and in terms of finding the right prebuilt image which would be correctly maintained. Performance increase seems to have a geometric mean of only 3-5% in the end. It is not like we are eating resources and we would save lots of OPEX/CAPEX by saving 5%.

benoit74 avatar Oct 03 '25 15:10 benoit74

Yes to upgrading to 3.14 when it's released. Depending on your other python dependencies, that might not be possible immediately and you might have to upgrade only to 3.13 for a while.

As for using free-threaded python, I'm not in favor. I doubt it would have visible beneficial impact but the potential for issues is huge and given there's an effort to upgrade a lot of things, that sound like a bad timing.

rgaudin avatar Oct 03 '25 15:10 rgaudin