--- id: prefixed version: "0.9.0" license: MPLv2.0 license_treatment: copyleft maintenance: aging --- # prefixed — Prefixed alternative numeric library License: copyleft · Maintenance: aging · Downloads: 903.6K/mo ## What it is and what it does Prefixed extends Python's built-in float with custom formatting directives that automatically scale numbers into human-readable form with SI or IEC prefixes. When you format a Float instance using 'h' (SI), 'k' (IEC full), or 'm' (IEC short) presentation types, the number is divided by the appropriate power of 10 or 2 and paired with the corresponding prefix symbol—so 3250 becomes '3.25k', and 0.00001534 becomes '15.34μs'. The class inherits from float, so it behaves identically to a regular float in arithmetic and comparisons; math operations with other real numbers return Float instances, preserving the formatting capability. The package supports a wide range of prefixes: SI includes Quetta down to Quecto, while IEC covers Yobi down to Kibi. You can also initialize Float from strings like '2k' or '2Ki' and they parse correctly. Additional formatting options include significant-digit mode (uppercase presentation types), margin adjustment to shift prefix thresholds, and a space-before-prefix flag. Use it for: - Display file sizes or network throughput with binary prefixes: format(Float(42467328), '.2k') + 'B' yields '40.50MiB'. - Format scientific measurements with SI prefixes: represent time intervals like 15.34 microseconds or frequency in gigahertz. - Parse and work with human-readable numeric strings in configuration or user input: Float('2k') == 2000.0. - Build terminal output or logging that scales automatically: avoid hardcoding unit conversions for different magnitude ranges. ## Worth the install? AI-flagged interpretation of the facts above — verify before relying. Prefixed provides a Float subclass that formats numbers with SI (decimal) and IEC (binary) prefixes in f-strings and format() calls, supporting units like k, M, G for SI and Ki, Mi, Gi for IEC. Yes, if you need automatic SI or IEC prefix formatting for numeric display. The package is stable, has no dependencies, and works across Python 2.7 and 3.5–3.13. The aging maintenance status is a minor concern for new features but not a blocker for a focused, mature library. MPLv2.0 copyleft licensing requires disclosure of modifications if you redistribute. ## Install pip install prefixed uv add prefixed poetry add prefixed ## Installing prefixed Before you install: Low install friction with no runtime dependencies. Maintenance status is aging—last release was in September 2024, though the repository remains active. License in practice: Licensed under MPLv2.0 (copyleft). You must disclose source code modifications and distribute under the same license if you modify and redistribute the package. Quickstart: from prefixed import Float f'{Float(3250):.2h}' # Output: '3.25k' f'{Float(0.00001534):.2h}s' # Output: '15.34μs' Verify before relying: - Whether the aging maintenance status affects stability or bug-fix responsiveness for your use case. - Compatibility with Python versions beyond 3.13 or future breaking changes in the float formatting API. ## Package facts - License: MPLv2.0 (copyleft) - Python support: unspecified - Install friction: low - Maintenance: aging - Downloads: 903.6K/month (top 5,000 on PyPI) - Known vulnerabilities: none known ## Tags SI prefix formatting, IEC binary prefix display, number formatting with units, metric prefix float, engineering notation formatter, number-formatting, si-iec-prefixes [View on SkillFed](https://skillfed.io/packages/prefixed) · [View on PyPI](https://pypi.org/project/prefixed/)