polar
polar copied to clipboard
Python free-threading support
trafficstars
Now that free-threading (aka no-GIL) is a thing in Python 3.14, it could be interesting to explore if we can migrate to that. Not sure what kind of performance gain we could get, but it's worth to check.
The main blockers right now are libraries with C extensions that have not been adapted yet to this new mode.
Dependency blockers
sqlalchemy(ready, to release in 2.1): https://github.com/sqlalchemy/sqlalchemy/issues/12881- but... asyncio features rely on
greenlet, which doesn't seem to aim at supporting free-threading: https://github.com/python-greenlet/greenlet/issues/423
- but... asyncio features rely on
asyncpg: https://github.com/MagicStack/asyncpg/pull/1279httptools(dependency of Uvicorn): https://github.com/MagicStack/httptools/issues/118
Experiments
2025-10-18
Tried to run the API with:
env PYTHON_GIL=0to avoidgreenletwarning- Installed
asyncpgfrom https://github.com/MagicStack/asyncpg/pull/1279 --http h11option of Uvicorn to avoid 3
Server is starting, can serve a few requests, but then blocks and doesn't answer new requests. Probably a concurrency problem with greenlet.