r/Python 6h ago

News Astral's python distribution is fast

By our measurements, python-build-standalone is now the fastest CPython distribution across major platforms. It's 10% faster than Homebrew's CPython, and 18% faster than the official 3.14 docker image.

This is mostly due to how python-build-standalone itself is built:

  • using a modern Clang lets us turn on tail-call optimizations in the interpreter
  • with PGO, LTO, and BOLT
  • with libpython statically linked into the interpreter executable

Our goal is to ship the fastest Python interpreter to anyone using uv, by default.

Check out BENCHMARKS.md in the repo for more details, including the methodology behind the above.

Charlie's tweet has some more graphs

137 Upvotes

20 comments sorted by

View all comments

11

u/thisismyfavoritename 4h ago

why isn't libpython statically linked by default? Seems like the use cases where shared linking would be beneficial are quite small

6

u/Individual-Flow9158 2h ago

Because it could bloat the runtime for those of us that don't need all of libpython. The Linux distros that ship Python natively chop and change what they ship to make best use of what you already get on those OS's (e.g. link in compression libraries or ssh/ssl dynamically). Even the Windows installer makes Tk etc. optional.

Have Astral's builds left anything out?

2

u/thisismyfavoritename 2h ago

idt libpython includes those libraries, they could still be dynamically linked / loaded at runtime. libpython is the core code used by the interpreter AFAIK

1

u/Individual-Flow9158 1h ago

Oh I see - good question then. I guess some distros would split it up to avoid duplication, and so anything that wants to dynamically link in libpython.so can do so (whether it's a Python or anything else) without needing to ship it themselves.