skillfed

binary

binary v1.0.2 241.4K downloads/30d#8,877 on PyPI10
Permissive license MIT OR Apache-2.0 AGING released

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 binary

uv

uv add binary

poetry

poetry add binary

Installing 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

Development Status :: 4 - BetaIntended Audience :: DevelopersNatural Language :: EnglishOperating System :: OS IndependentProgramming Language :: Python :: 3Programming Language :: Python :: 3 :: OnlyProgramming Language :: Python :: 3.10Programming Language :: Python :: 3.11Programming Language :: Python :: 3.12Programming Language :: Python :: 3.13Programming Language :: Python :: 3.9Programming Language :: Python :: Implementation :: CPythonProgramming Language :: Python :: Implementation :: PyPy

Tags

binary decimal unit conversionstorage size conversionIEC SI unitsbytes to megabyteshuman readable file sizesunit conversion librarybinary prefix conversion
unit-conversionstorage-metrics

More Utilities packages