Skip to content

Releases: timlnx/bitmath

2.0.0 Is finally out!

26 Apr 00:18
v2.0.0
bd2873f

Choose a tag to compare

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 a Capacity(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 on DeviceIoControl. Linux and Windows are both supported; macOS raises NotImplementedError because SIP blocks raw block-device access even for root.
  • Capacity math. bitmath objects now support floor division (//), modulo (%), and divmod — 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. The NIST_PREFIXES, NIST_STEPS, and ALL_UNIT_TYPES constants reflect reality again.
  • Thread-safe context manager. bitmath.format() now uses threading.local with 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. Use parse_string(..., strict=False). The old name still works but emits a DeprecationWarning.
  • bitmath.integrations has 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.
  • Byte and Bit display as B and b, 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() raises NotImplementedError on macOS. Use query_capacity() instead.
  • setup.py is gone. Install via pip install bitmath; build via python -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.integrations module 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.int64 support 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

23 Apr 17:56
v2.0.0-rc4
bd2873f

Choose a tag to compare

Pre-release

What's Changed

Full Changelog: v2.0.0-rc3...v2.0.0-rc4

Almost 2.0.0

23 Apr 12:19
v2.0.0-rc3
2d0508d

Choose a tag to compare

Almost 2.0.0 Pre-release
Pre-release

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

Full Changelog: v2.0.0-rc2...v2.0.0-rc3

2.0.0 Release Candidate 2

21 Apr 22:23
e3006de

Choose a tag to compare

Pre-release

Testing RPM building from RCs

2.0.0 Release Candidate 1

19 Apr 01:35
83a8170

Choose a tag to compare

Pre-release

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

17 Apr 03:10
9405a02

Choose a tag to compare

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

Full Changelog: 1.3.3.1...1.4.0.1