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
libopenblas64_.so is by far the biggest fish here. For a regular x86-64 manylinux wheel, we're at 14.8 MB for numpy 1.26.2, and >50% of that is in numpy.libs.
If you build a wheel without vendored libopenblas (through python -m build), then it's about 7.8 MB. If you unzip it, you find the following:
total unzipped size: 28.9 MB
_multiarray_umath.so: 8.2 MB
_simd.so: 3.4 MB
_core/tests/: 3.3 MB
all other tests/ combined: ~3.4 MB
numpy/random/*.so: 3.2 MB
It looks like separating out the tests could be the easiest and most significant win after separating out libopenblas. The two static libraries are only ~200 kb together so not that relevant.
I don't see a realistic way to do that, one cannot distinguish between CI jobs and other regular uses. Also, it's not at all clear that most usage is for CI. It seems unlikely actually - all we know is that ~90% of jobs are for Linux. 200 million CI jobs/month would be a lot. The distribution over Python versions, with 3.12 still very low 4 months after it was released, rather suggests that it's large-scale production deployments of applications and data pipelines:
Basically my strategy is use .gitattributes to remove tests from the sdist (and use setuptools to build wheels for the tests separetely), then build the wheel from the sdist without tests.
I'd be more inclined to keep tests in the sdist (distros need it after all) and use a build flag to allow removing tests from wheels. But I'm certainly not sure that that's the way to go before trying.
Another alternative for the test suite, if we want it to be included by default, is to compress it.
That could help a bit, but probably not all that much compared to not shipping them - wheels are already compressed after all (they're zip archives).
Reacted by Stefan van der Walt, czgdp1807 and Agriya Khetarpal
@lithomas1 I think we (@czgdp1807 and I) have just figured out a much cleaner way of doing this, using install tags, which are specifically meant for this kind of thing. I think the diff will end up being quite small, and it retains the flexibility to install tests yes/no with a single CLI flag. It should also allow producing two wheels (separate numpy_tests one for the tests package) without a rebuild. You may want to hold off on merging your Pandas PR to see whether this will work out for numpy. We should have a PR to look at sometime within the next week.
A very brief summary of the benefits of binary size reductions:
The reduction in PyPI network traffic is very large. The reductions from dropping the tests (~1.6 MB wheel size change) alone will be ~4 PB at current download rates, which is massive. The CDN egress cost of that at current commercial rates (looks like ~$0.025/GB from glancing at AWS et al. pricing pages) is $100,000/year. Sponsored by PyPI's CDN providers so not a real cost for the community now, but at least a liability. And it also hints at the environmental costs, which is important.
Usability for the average user improves, smaller is better (faster environment construction etc.)
Reducing the size of the vendored OpenBLAS wheel (xref MacPython/openblas-libs#144) will help more, and succeeding in splitting it off completely even more. The macOS Accelerate wheels show what is possible: they are now (for 2.0.0rc1) 5.0-5.2 MB, and without tests they are 3.4-3.6 MB. The manylinux2014_x86_64 wheels for 2.0.0rc1 are 19.0-19.3 MB.
For packages that make pyinstaller bundles it's a big win making scipy and numpy smaller. Two lots of openblas that dont have to be bundled, tests that don't have to be shipped, etc. I think some of the binaries I was releasing were on the 100Mb level and higher.
Thanks to @Mousius I just realized that this is a test-only file, so we can remove it from the installed package as well if tests aren't requested. That's another 10% won, at least on x86-64 (gain on other platforms is significantly smaller).
gh-33074 (drop libquadmath, link libgfortran statically) helped quite a bit here: the cp314-manylinux_...x86_64 wheel for 2.5.4 is 16.7 MB, while for 2.6.0.dev0 it's 15.4 MB.
Here is an updated wheel size breakdown for NumPy 2.5.5, using the py3.14 manylinux x86-64 wheel (numpy-2.5.5-cp314-cp314-manylinux_2_27_x86_64.manylinux_2_28_x86_64.whl).
The wheel is 15.72 MB compressed and **52.77 MB uncompressed:
Component
Compressed
Share of wheel
Vendored OpenBLAS (numpy.libs/)
7.472 MB
47.5%
numpy/_core/_multiarray_umath.so
3.273 MB
20.8%
Test directories (Python tests + data/fixtures)
1.601 MB
10.2%
Six compiled test extensions
0.356 MB
2.3%
Everything else, including ZIP overhead
3.016 MB
19.2%
Total
15.718 MB
100%
I simulated splitting out tests by removing files from the wheel, regenerating its RECORD and then rezipping:
Option
Resulting NumPy wheel
Saving
Move test directories (including fixtures), keep test-only extensions in numpy
14.01 MB
1.71 MB (10.9%)
Move test directories and all six compiled test extensions
13.65 MB
2.07 MB (13.1%)
The six test extensions take up 0.356 MB compressed / 1.803 MB installed. Most of that is numpy._core._simd (0.252 MB compressed / 1.506 MB installed). The test directories themselves occupy 6.88 MB installed, so that's the on-disk size saved.
Based on this, I think removing only the pure Python test files is the most pragmatic next step, since that gets us most of the gain while only requiring a single none-any wheel, rather than a battery of 60+ test wheels. That's gh-26289.
Is it ever going to be possible to not delocate openblas, but just install a scipy_ooenblas wheel instead? I think I probably got told the answer to this at some point, but I can't remember.
EDIT: it was discussed above, but I can't remember what the roadblock is.
@andyfaff beyond the "it only helps a lot if numpy and scipy actually use the same flavor (ILP64 vs. LP64)", the main issue is packaging standards. We can't declare it in project.dependencies statically in a reasonable way, since it's so PyPI-specific and doesn't make sense for the sdist on PyPI nor for redistributors. So we'll either need to declare it as dynamic which has downsides, or need a version of PEP 725 that says "on PyPI, this external dependency is provided by package X" which can map the external blas/lapack dependencies to scipy-openblas64.
Activity
rgommers commentedon Jan 31, 2024
libopenblas64_.sois by far the biggest fish here. For a regular x86-64 manylinux wheel, we're at 14.8 MB for numpy 1.26.2, and >50% of that is innumpy.libs.If you build a wheel without vendored libopenblas (through
python -m build), then it's about 7.8 MB. If you unzip it, you find the following:_multiarray_umath.so: 8.2 MB_simd.so: 3.4 MB_core/tests/: 3.3 MBtests/combined: ~3.4 MBnumpy/random/*.so: 3.2 MBIt looks like separating out the tests could be the easiest and most significant win after separating out
libopenblas. The two static libraries are only ~200 kb together so not that relevant.stefanv commentedon Jan 31, 2024
Would we make the tests optionally installable, or how would users validate that their NumPy installation is working correctly?
rgommers commentedon Jan 31, 2024
We could publish a
numpy-testspackage indeed. And/or a build-time switch like-Dinclude-tests=true.mattip commentedon Feb 1, 2024
So the idea would be that most "only CI testing" people would get a non-optimized NumPy without tests, and "normal users" would download OpenBLAS?
rgommers commentedon Feb 1, 2024
I don't see a realistic way to do that, one cannot distinguish between CI jobs and other regular uses. Also, it's not at all clear that most usage is for CI. It seems unlikely actually - all we know is that ~90% of jobs are for Linux. 200 million CI jobs/month would be a lot. The distribution over Python versions, with 3.12 still very low 4 months after it was released, rather suggests that it's large-scale production deployments of applications and data pipelines:
stefanv commentedon Feb 5, 2024
Another alternative for the test suite, if we want it to be included by default, is to compress it.
lithomas1 commentedon Feb 14, 2024
I think I've figured out how to remove the tests for pandas, if you're interested.
pandas-dev/pandas#53007 is my attempt.
Basically my strategy is use
.gitattributesto remove tests from the sdist (and use setuptools to build wheels for the tests separetely), then build the wheel from the sdist without tests.rgommers commentedon Feb 14, 2024
Interesting, thanks for sharing @lithomas1.
I'd be more inclined to keep tests in the sdist (distros need it after all) and use a build flag to allow removing tests from wheels. But I'm certainly not sure that that's the way to go before trying.
That could help a bit, but probably not all that much compared to not shipping them - wheels are already compressed after all (they're zip archives).
stefanv commentedon Feb 14, 2024
Yeap, sorry for the noise. Compression advantage of something like zstd over gz is only a few 100k.
I wish wheels supported better compression. Looks like they considered it but never got zstd or similar into the standard lib.
rgommers commentedon Apr 12, 2024
@lithomas1 I think we (@czgdp1807 and I) have just figured out a much cleaner way of doing this, using install tags, which are specifically meant for this kind of thing. I think the diff will end up being quite small, and it retains the flexibility to install tests yes/no with a single CLI flag. It should also allow producing two wheels (separate
numpy_testsone for the tests package) without a rebuild. You may want to hold off on merging your Pandas PR to see whether this will work out for numpy. We should have a PR to look at sometime within the next week.rgommers commentedon Apr 16, 2024
gh-26274 allows removing the tests, and looks quite clean. Reduction in wheel sizes will be 1.6 MB.
rgommers commentedon Apr 22, 2024
A very brief summary of the benefits of binary size reductions:
Reducing the size of the vendored OpenBLAS wheel (xref MacPython/openblas-libs#144) will help more, and succeeding in splitting it off completely even more. The macOS Accelerate wheels show what is possible: they are now (for
2.0.0rc1) 5.0-5.2 MB, and without tests they are 3.4-3.6 MB. Themanylinux2014_x86_64wheels for 2.0.0rc1 are 19.0-19.3 MB.andyfaff commentedon Apr 22, 2024
For packages that make pyinstaller bundles it's a big win making scipy and numpy smaller. Two lots of openblas that dont have to be bundled, tests that don't have to be shipped, etc. I think some of the binaries I was releasing were on the 100Mb level and higher.
tylerjereddy commentedon Apr 22, 2024
I'm not a huge fan of the extra complexity re: separate test suite "package" FWIW, but looks like I'll be outvoted, fair enough.
rgommers commentedon Jul 17, 2024
Thanks to @Mousius I just realized that this is a test-only file, so we can remove it from the installed package as well if
testsaren't requested. That's another 10% won, at least on x86-64 (gain on other platforms is significantly smaller).rgommers commentedon Oct 21, 2026
gh-33074 (drop
libquadmath, linklibgfortranstatically) helped quite a bit here: thecp314-manylinux_...x86_64wheel for 2.5.4 is 16.7 MB, while for 2.6.0.dev0 it's 15.4 MB.rgommers commentedon Nov 22, 2026
Here is an updated wheel size breakdown for NumPy 2.5.5, using the py3.14 manylinux x86-64 wheel (
numpy-2.5.5-cp314-cp314-manylinux_2_27_x86_64.manylinux_2_28_x86_64.whl).The wheel is 15.72 MB compressed and **52.77 MB uncompressed:
numpy.libs/)numpy/_core/_multiarray_umath.soI simulated splitting out tests by removing files from the wheel, regenerating its
RECORDand then rezipping:numpyThe six test extensions take up 0.356 MB compressed / 1.803 MB installed. Most of that is
numpy._core._simd(0.252 MB compressed / 1.506 MB installed). The test directories themselves occupy 6.88 MB installed, so that's the on-disk size saved.Based on this, I think removing only the pure Python test files is the most pragmatic next step, since that gets us most of the gain while only requiring a single
none-anywheel, rather than a battery of 60+ test wheels. That's gh-26289.Downloads have been increased massively recently, so the payoff for this is getting larger quickly. 1.13 billion/month (see https://pypistats.org/packages/numpy) and the graph at https://clickpy.clickhouse.com/dashboard/numpy shows the growth over years (the dip is a PyPI stats adjustment where they stopped counting mirrors):
andyfaff commentedon Nov 23, 2026
Is it ever going to be possible to not delocate openblas, but just install a scipy_ooenblas wheel instead? I think I probably got told the answer to this at some point, but I can't remember.
EDIT: it was discussed above, but I can't remember what the roadblock is.
rgommers commentedon Nov 23, 2026
@andyfaff beyond the "it only helps a lot if
numpyandscipyactually use the same flavor (ILP64 vs. LP64)", the main issue is packaging standards. We can't declare it inproject.dependenciesstatically in a reasonable way, since it's so PyPI-specific and doesn't make sense for the sdist on PyPI nor for redistributors. So we'll either need to declare it asdynamicwhich has downsides, or need a version of PEP 725 that says "on PyPI, this external dependency is provided by package X" which can map the externalblas/lapackdependencies toscipy-openblas64.