You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
Questions about libpython size, specifically on Linux x86_64 #275
Several possibly-related questions. Note that I'm not necessarily saying anything is "wrong" here, I'm just trying to understand the differences.
So I've noticed two things about libpython.3.xx.so.1.0, working on x86_64-unknown-linux-gnu:
Python 3.12's libpython is 4x the size of Python 3.11: 212MB vs. 58MB. If you strip both of them, the size difference largely vanishes; Python 3.12 is 25.3MB, where Python 3.11 is 24.4MB.
python-build-standalone's stripped libpython is still something like 4x larger than the libpython that comes with Fedora 40, which is 6.1MB for Python 3.12 and 4.9MB for Python 3.11.
This is particularly noticeable when developing standalone binaries with PyInstaller. I've hacked PyInstaller locally to work with python-build-standalone, but the resulting binaries are nearly 3x the size compared to building with Fedora's python even if I build with the stripped libpython, which is kind of rough.
Reacted by Mark Blakeney, Jack Cherng, Alex DeLorenzo and John Hagen
Python 3.12's libpython is 4x the size of Python 3.11: 212MB vs. 58MB. If you strip both of them, the size difference largely vanishes; Python 3.12 is 25.3MB, where Python 3.11 is 24.4MB.
Thanks for this information. I was wondering why my PyInstaller-packaged APP became much larger. 😄
Thanks for this information. I do have a script for installation so I can add a strip step during installing. Currently I just use strip without any CLI flags. Do you have recommended flags?
I wonder if the debug symbols size has something to do with BOLT, which is 3.12+ only. Maybe BOLT is producing sub-optimal DWARF records, not preserving compression in symbols, or something along those lines.
I also see that if I install python using UV, the sizes are quite a bit bigger than if I use python slim in docker.
Note that the libpython3.13.so is almost 6x larger in UV (python-build-standalone) than in slim. I don't have an option in UV to install the stripped version maybe? If so I will make an issue there. But it also seems that this packs tcl, tk and some other things which I guess are optional as they aren't packed in -slim. So could we make a minimized python standalone for docker case? I know that it will be larger than python:x-slim base images, but I'm fine with that, because using UV is very convenient and universal when using different base images. But currently the difference in size is 78.1MB (slim) vs 120MB (ubuntu24+python-by-uv), so almost a third. Would be good to get closer, and it seems we could get there if .so's where similar size.
Activity
jfcherng commentedon Jun 28, 2024
Thanks for this information. I was wondering why my PyInstaller-packaged APP became much larger. 😄
bulletmark commentedon Jun 28, 2024
See also related discussion here.
jfcherng commentedon Jun 28, 2024
Thanks for this information. I do have a script for installation so I can add a
stripstep during installing. Currently I just usestripwithout any CLI flags. Do you have recommended flags?bulletmark commentedon Jun 28, 2024
My installer uses
strip -p --strip-unneeded.indygreg commentedon Jul 13, 2024
I wonder if the debug symbols size has something to do with BOLT, which is 3.12+ only. Maybe BOLT is producing sub-optimal DWARF records, not preserving compression in symbols, or something along those lines.
charliermarsh commentedon Jul 14, 2024
FWIW on macOS, I only see a ~12% reduction in
libpython3.10.dylibsize.Add `install_only_stripped` binaries to release (#279)
Add `install_only_stripped` binaries to release (astral-sh#279)
TheExDeus commentedon May 23, 2025
I also see that if I install python using UV, the sizes are quite a bit bigger than if I use python slim in docker.
Note that the libpython3.13.so is almost 6x larger in UV (python-build-standalone) than in slim. I don't have an option in UV to install the stripped version maybe? If so I will make an issue there. But it also seems that this packs tcl, tk and some other things which I guess are optional as they aren't packed in -slim. So could we make a minimized python standalone for docker case? I know that it will be larger than python:x-slim base images, but I'm fine with that, because using UV is very convenient and universal when using different base images. But currently the difference in size is 78.1MB (slim) vs 120MB (ubuntu24+python-by-uv), so almost a third. Would be good to get closer, and it seems we could get there if .so's where similar size.
johnthagen commentedon Aug 11, 2025
Some Pyinstaller comments upstream that might be relevant