prefixed
Prefixed alternative numeric library
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 on this page — 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
prefixed on PyPI
pip
pip install prefixeduv
uv add prefixedpoetry
poetry add prefixedInstalling 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 | not specified |
| Install friction | low — pure-Python wheel |
| Runtime dependencies | none |
| Maintenance | aging — 711 days since the last release |
| Last repo commit | |
| First released | |
| Downloads | 903,562/month — #4,767 on PyPI (30-day window, as of 2026-08-14) |
| Known vulnerabilities | none known (OSV.dev, checked 2026-08-14) |
Evidence: prefixed-0.9.0-py2.py3-none-any.whl
Keywords: si, iec, prefix, nist
Tags
More Terminals packages
Wraps any iterable to display a real-time…
copyleft · top 100 on PyPI
richRich renders styled text, tables, progress…
permissive · top 100 on PyPI
coloramaColorama makes ANSI escape sequences for…
permissive · top 100 on PyPI
wcwidthMeasures the displayed width of Unicode strings…
permissive · top 1,000 on PyPI
ptyprocessRun a subprocess in a pseudo terminal (pty) and…
permissive · top 1,000 on PyPI
pexpectPexpect spawns and controls interactive console…
permissive · top 1,000 on PyPI
binaryConverts between binary (IEC) and decimal (SI)…
permissive · top 15,000 on PyPI
bitmathbitmath converts and performs arithmetic on…
permissive · top 15,000 on PyPI
sigfigRounds numbers by significant figures, decimal…
permissive · top 5,000 on PyPI
py-multicodecWraps data with self-describing multicodec…
permissive · top 15,000 on PyPI
pksuidGenerates prefixed, k-sortable unique…
permissive · top 15,000 on PyPI
flake8-use-fstringA flake8 plugin that detects and flags…
permissive · top 15,000 on PyPI
prefixdateParses date strings with partial precision…
permissive · top 5,000 on PyPI
roundersProvides drop-in replacements for Python's…
permissive · top 15,000 on PyPI
mgrsConverts between MGRS (Military Grid Reference…
permissive · top 15,000 on PyPI
overpunchParses and formats overpunch-encoded numbers, a…
permissive · top 15,000 on PyPI