Why Package Size Matters More Than You Think
Every day, thousands of Python packages are uploaded to PyPI. Many of us check the wheel size before installing and think "oh, it's lightweight!" — but that's just the tip of the iceberg.
A package might only be 50 KB on its own, but when you install it, you could be pulling in hundreds of megabytes of transitive dependencies. The package advertises itself as "lightweight," but what your users actually download is something entirely different.
This is exactly the problem pip-size solves.
What is pip-size?
pip-size calculates the real download size of PyPI packages — including all their dependencies — without actually downloading anything. It uses the PyPI JSON API to resolve the entire dependency tree and shows you the full picture before you run pip install.
Quick Example
$ pip-size requests
🔍 Resolving 'requests'...
✓ requests==2.32.5 → requests-2.32.5-py3-none-any.whl
✓ urllib3==2.3.0 → urllib3-2.3.0-py3-none-any.whl
✓ charset-normalizer==3.4.1 → charset_normalizer-3.4.1-py3-none-any.whl
✓ certifi==2025.1.31 → certifi-2025.1.31-py3-none-any.whl
✓ idna==3.10 → idna-3.10-py3-none-any.whl
requests==2.32.5 63.2 KB (total: 834.8 KB)
├── urllib3==2.3.0 341.8 KB
├── charset-normalizer==3.4.1 204.8 KB
├── certifi==2025.1.31 164.0 KB
└── idna==3.10 61.4 KB
See? requests itself is only 63.2 KB, but the total cost is 834.8 KB — over 13x more than the package alone!
Why This Matters
1. Fair Comparison Between Alternatives
Want to compare httpx vs requests vs aiohttp? Don't just look at their individual sizes — compare the full dependency tree:
pip-size httpx
pip-size requests
pip-size aiohttp
Now you can make an informed decision based on what users will actually download.
2. Audit Your Own Packages
If you maintain a package, you might be surprised what your "lightweight" library is actually shipping. Run:
pip-size your-package
3. Spot Heavy Dependencies
Ever wondered why a simple CLI tool pulls in 200 MB? pip-size shows you exactly which dependency is responsible for the bulk of the size.
4. CI Automation
Use --quiet or --bytes to integrate size checks into your CI pipeline:
pip-size mypackage --quiet
# Output: 1234567
Installation
pip install pip-size
Key Features
- Zero downloads — uses PyPI JSON API only
- Full dependency tree — includes all transitive dependencies
-
Extras support — see how
requests[security]affects size - Proxy support — works with HTTP, SOCKS4, and SOCKS5 proxies
- Caching — 24-hour cache to avoid repeated API calls
- JSON output — integrate with your own tools
The Bigger Picture
We often obsess over code performance, but install size is an overlooked dimension of developer experience. Every megabyte you force users to download:
- Slows down CI/CD pipelines
- Increases container image sizes
- Wastes bandwidth, especially in regions with limited connectivity
- Frustrates users on slow connections
pip-size is my small step toward raising awareness about this issue. I hope it helps you make better decisions when choosing dependencies — and when publishing your own packages.
Give it a try and let me know what you think!
GitHub: mohammadraziei/pip-size
Top comments (0)