binary
What it is and what it does
binary is a lightweight unit-conversion library that translates between binary (IEC-standard: KiB, MiB, GiB, etc.) and decimal (SI-standard: KB, MB, GB, etc.) storage units. It solves the common problem of converting between what manufacturers advertise (decimal terabytes) and what operating systems report (binary tebibytes), and vice versa. The package exposes a single function, convert_units(), which accepts a number, an input unit, and optionally a target unit, and returns both the converted value and a human-readable unit string.
The library supports automatic scaling to the highest appropriate unit, optional exact arithmetic via Python's decimal.Decimal module, and negative values. It conforms to IEC 80000-13 and SI standards, making it suitable for storage calculations, system monitoring, and any context where precise unit conversion matters. With no external dependencies and support for Python 3.9 through 3.13, it installs cleanly and runs on both CPython and PyPy.
Use it for:
- Display hard drive capacity in human-readable form, converting manufacturer specs (decimal TB) to actual storage (binary TiB).
- Format network traffic or throughput metrics for logs or dashboards with automatic unit selection.
- Calculate storage requirements in infrastructure-as-code or Kubernetes manifests, ensuring unit consistency.
- Convert between binary and decimal units in scientific or engineering calculations where precision matters.
- Validate or normalize storage quantities in APIs or configuration files.
Worth the install?
AI-flagged interpretation of the facts on this page — verify before relying
Converts between binary (IEC) and decimal (SI) units for storage sizes, with support for exact decimal arithmetic and automatic unit scaling.
Yes, if you need reliable unit conversion between binary and decimal storage units. The package is simple, dependency-free, and permissively licensed. The aging maintenance status (last release 429 days ago) is a minor concern for a stable, narrow-scope library with no known vulnerabilities, but check whether active development matters for your use case. Suitable for production use in storage, monitoring, or infrastructure contexts.
Install
binary on PyPI
pip
pip install binaryuv
uv add binarypoetry
poetry add binaryInstalling binary
Before you install
Low friction installation with no runtime dependencies. Maintenance is aging—last release was 429 days ago, though the repository remains active and supports current Python versions (3.9–3.13).
License in practice
Dual-licensed under MIT or Apache-2.0 at your option, both permissive. No restrictions on commercial or private use.
Quickstart
pip install binary
from binary import BinaryUnits, DecimalUnits, convert_units
# Convert 1536 KB to MB in binary units
amount, unit = convert_units(1536, BinaryUnits.KB, BinaryUnits.MB)
print(f"{amount} {unit}") # Output: 1.5 MiB
Requires Python 3.9 or later.
Verify before relying
- Whether the package handles edge cases like very large numbers or unusual unit combinations reliably.
- Performance characteristics when exact=True (using decimal.Decimal) on large datasets.
Package facts
| License | MIT OR Apache-2.0 (permissive) |
| Python support | supports the current Python release (>=3.9) |
| Install friction | low — pure-Python wheel |
| Runtime dependencies | none |
| Maintenance | aging — 429 days since the last release |
| Last repo commit | |
| First released | |
| Downloads | 241,411/month — #8,877 on PyPI (30-day window, as of 2026-08-14) |
| Known vulnerabilities | none known (OSV.dev, checked 2026-08-14) |
Evidence: binary-1.0.2-py3-none-any.whl
Tags
More Utilities packages
Converts domain names between Unicode and…
permissive · top 100 on PyPI
charset-normalizerDetects and normalizes text encoding from…
permissive · top 100 on PyPI
setuptoolsSetuptools is a Python build backend and…
permissive · top 100 on PyPI
pluggyPluggy provides a plugin system that lets you…
permissive · top 100 on PyPI
PygmentsPygments is a syntax highlighter that colorizes…
permissive · top 100 on PyPI
sixSix provides utility functions to write Python…
permissive · top 100 on PyPI
bitmathbitmath converts and performs arithmetic on…
permissive · top 15,000 on PyPI
prefixedPrefixed provides a Float subclass that formats…
copyleft · top 5,000 on PyPI
hurry.filesizeConverts byte counts into human-readable file…
unclear · top 15,000 on PyPI
ansys-unitsManages physical quantities with numerical…
permissive · top 15,000 on PyPI
PintPint defines, operates on, and converts between…
permissive · top 5,000 on PyPI
measurementProvides unit-aware measurement objects for…
permissive · top 5,000 on PyPI
unytAttaches units to NumPy arrays and provides…
permissive · top 15,000 on PyPI
isqxisqx provides type-annotation-friendly metadata…
permissive · top 15,000 on PyPI
humanreadableParses human-readable time and bitrate strings…
permissive · top 15,000 on PyPI
hepunitsProvides units and physical constants in the…
permissive · top 15,000 on PyPI