--- id: bitmath version: "2.1.1" license: unclear license_treatment: permissive maintenance: active --- # bitmath — Pythonic module for representing and manipulating file sizes with different prefix notations (file size unit conversion) License: permissive · Maintenance: active · Downloads: 396.9K/mo ## What it is and what it does bitmath is a Python library for working with file sizes in different unit systems. It handles conversion between SI units (kB, MB, GB) and NIST binary units (KiB, MiB, GiB, and up to YiB), letting you treat sizes as first-class objects that support arithmetic, comparison, and formatting. The library includes no external dependencies beyond Python's standard library. You use it when you need to convert between unit systems, perform capacity calculations (like fitting files on a drive), or display file sizes in human-readable form. It supports floor division and modulo for capacity planning (e.g., how many 300 MiB chunks fit in 1 GiB), rich comparisons so 1024 Bytes equals 1 KiB, and integrates with Python's format protocol and argparse for CLI tools. Use it for: - Convert storage sizes between SI and NIST units for display or calculation in file management tools. - Calculate how many files or chunks fit on a device using floor division and modulo operations. - Format file sizes for human-readable output in logs, reports, or interactive shells. - Perform arithmetic on sizes (subtract, divide, compare) without manual unit conversion. - Parse and validate file size input from command-line arguments or user configuration. ## Worth the install? AI-flagged interpretation of the facts above — verify before relying. bitmath converts and performs arithmetic on file sizes across SI and NIST prefix units (kB to YiB), with support for human-readable formatting, rich comparisons, and capacity math. Yes. bitmath is actively maintained, has no dependencies, installs cleanly, carries permissive MIT licensing, and solves a concrete problem—file size unit conversion and arithmetic—that many tools need. Use it whenever you work with storage sizes and want to avoid manual conversion logic or string parsing. ## Install pip install bitmath uv add bitmath poetry add bitmath ## Installing bitmath Before you install: Low friction: pure Python wheel with no runtime dependencies. Actively maintained with a recent release 81 days ago and ongoing repository activity. License in practice: MIT license permits unrestricted use, modification, and distribution in both open and closed projects with minimal obligations. Quickstart: pip install bitmath import bitmath log_size = bitmath.kB(137.4) log_zipped = bitmath.Byte(987) print(log_size - log_zipped) Requires Python 3.9 or newer. ## Package facts - License: not declared (permissive) - Python support: supports_current - Install friction: low - Maintenance: active - Downloads: 396.9K/month (top 15,000 on PyPI) - Known vulnerabilities: none known ## Tags file size unit conversion, byte size arithmetic, SI NIST prefix conversion, human readable file sizes, storage capacity math, GiB MiB KiB conversion, file size formatting, file-size-conversion, unit-conversion, storage-math [View on SkillFed](https://skillfed.io/packages/bitmath) · [View on PyPI](https://pypi.org/project/bitmath/)