Releases: timlnx/bitmath
2.0.0 Is finally out!
bitmath 2.0.0
First major release in eight years. Python 3 only, one breaking pivot, and the decade-long backwards-compatibility guarantee still intact for any 1.x code already running on Py3.
Highlights
- Python 3.9+ only. Python 2 support is gone, as promised in issue #99.
- New
query_capacity()API — returns aCapacity(total, used, free)NamedTuple for any path or mount point. Cross-platform, no root required. This is the API you want for almost every "how big is this disk/volume?" question. - Windows disk capacity via
query_device_capacity(), built onDeviceIoControl. Linux and Windows are both supported; macOS raisesNotImplementedErrorbecause SIP blocks raw block-device access even for root. - Capacity math. bitmath objects now support floor division (
//), modulo (%), anddivmod— for chunk-and-remainder planning: how many 500 GB volumes fit into 14 TiB, and how much is left over? - f-string and
format()support. bitmath objects implement__format__per PEP 3101;f"{size:.2f} {size.unit}"→'1.69 GiB'. - Four new NIST units:
ZiB,YiB,Zib,Yib. TheNIST_PREFIXES,NIST_STEPS, andALL_UNIT_TYPESconstants reflect reality again. - Thread-safe context manager.
bitmath.format()now usesthreading.localwith proper save/restore semantics. Fixes #83. best_prefix()bit-family fix. Bit-family inputs no longer silently convert into byte-family outputs. Fixes #95.
Breaking changes
Python 2 is gone — that's the headline. Six smaller changes came along with it:
parse_string(..., strict=False)defaults to NIST, not SI. Inputs like"1g"may resolve differently than in 1.x.parse_string_unsafe()is deprecated. Useparse_string(..., strict=False). The old name still works but emits aDeprecationWarning.bitmath.integrationshas been removed. The argparse, click, and progressbar integrations are gone from the package; copy-paste equivalents are in the new Integration Examples chapter of the docs.ByteandBitdisplay asBandb, consistent with every other unit in the library. Class names are unchanged. Code that compared formatted strings against the literal words"Byte"or"Bit"will need updating.query_device_capacity()raisesNotImplementedErroron macOS. Usequery_capacity()instead.setup.pyis gone. Install viapip install bitmath; build viapython -m build.
If you're already on Python 3.9+ and using the documented 1.x API, the upgrade is probably a pip install --upgrade bitmath and a test run.
Under the hood
pyproject.toml + hatchling replace setup.py. pytest replaces nosetests. CI runs against Python 3.9–3.13 on Linux, macOS, and Windows. CodeQL runs on every push. Releases are GPG-signed.
Credits
Thanks to everyone who filed reports or contributed code during the gap between 1.3.3 and 2.0.
- Maximilian Blochberger (@blochberger) did substantial integration work in the 1.4 era — the click integration (closing #74) and the argparse/progressbar dependency separation (closing #86, his own report). The
bitmath.integrationsmodule itself has been retired in 2.0, but the copy-paste replacements in the Integration Examples chapter are based on his code. - Matthieu Coudron contributed
numpy.int64support for bitmath comparisons. - Jonathan Eunice (@jonathaneunice) contributed the original concept for
__format__support in PR #76, years before it finally landed. - @a-detiste opened PR #105, which is why the test suite now prefers stdlib
unittest.mock. - @postmaxin opened PR #107, which surfaced the pack
aging bug that 1.4 shipped to fix.
Issue reports that drove real fixes: @walrusVision for #83 (thread-safe context manager), @beav for #93 (Byte/Bit display), @rohit04saluja for #95 (best_prefix bit-family).
2.0.0 Release Candidate 4
Almost 2.0.0
All 2.0.0 milestones are complete in the issue tracker. Now I'm doing some manual checking before pushing the final 2.0.0 release.
What's Changed
- Claiming library with context7 by @timlnx in #118
- Refreshing docs by @timlnx in #119
- Py39 wrapup by @timlnx in #121
- Add Windows device capacity support via DeviceIoControl, closes #52 by @timlnx in #122
- docs: 2.0.0 final docs update (issue #123) by @timlnx in #124
Full Changelog: v2.0.0-rc2...v2.0.0-rc3
2.0.0 Release Candidate 2
Testing RPM building from RCs
2.0.0 Release Candidate 1
This is a pre-release build of 2.0.0 so I have something to use while I finish refactoring the RPM release tooling
1.4.0-maintenance
What's Changed
- Note that context managers are not thread-safe by @timlnx in #84
- Fix argparse integration requiring progressbar by @blochberger in #87
- Add click integration (closes #74) by @blochberger in #88
- Maintenance 1.4.0 by @timlnx in #108
- Add .readthedocs.yaml for RTD build configuration by @timlnx in #109
- Add sphinx_rtd_theme to doc-requirements.txt, remove unused sphinxcon… by @timlnx in #110
New Contributors
- @blochberger made their first contribution in #87
Full Changelog: 1.3.3.1...1.4.0.1