bitmath is a Python library (version 1.3.3.1) for representing, converting, and manipulating file sizes with different prefix notations (SI and NIST). It provides functionality for unit conversion (e.g., kB to GiB), arithmetic operations, rich comparisons, and human-readable formatting. The library's core functionality is stable and widely used for precise file size handling, though its release cadence has stalled.
pip install bitmathVerified import paths — ran on the pinned version, not inferred.
Demonstrates how to instantiate bitmath objects, convert between units, perform basic arithmetic, and parse string representations of file sizes.
Avoid `bitmath.format()` in multi-threaded contexts; instead, use `instance.format()` directly on `bitmath` objects.
Ensure input strings conform to standard SI or NIST unit notations (e.g., '100 MiB', '5 GB') when using `bitmath.parse_string()`. If parsing unknown formats, consider `bitmath.parse_string_unsafe()` and review its documentation.
Run your application with appropriate administrative privileges when using `query_device_capacity()` on Linux/macOS. Be aware of platform limitations.
Explicitly convert numbers to `bitmath` types before performing operations, or carefully review the documentation for mixed-type operation behaviors.
Ensure input strings for `bitmath.parse_string()` use standard unit suffixes (e.g., 'GB', 'GiB'). For parsing more flexible or unconventional formats, use `bitmath.parse_string_unsafe()`.
Upgrade your `pip` installation to the latest version using `pip install --upgrade pip`. If a very old `pip` is unavoidable, a workaround historically suggested was to download the `bitmath` tarball from PyPI and install it manually: `pip install bitmath-x.y.z.tar.gz`.
No dependency data recorded yet.