skillfed

prefixed

Prefixed alternative numeric library

prefixed v0.9.0 903.6K downloads/30d#4,767 on PyPI27
Copyleft license MPLv2.0 AGING released

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 prefixed

uv

uv add prefixed

poetry

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 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

Development Status :: 4 - BetaIntended Audience :: DevelopersLicense :: OSI Approved :: Mozilla Public License 2.0 (MPL 2.0)Operating System :: Microsoft :: WindowsOperating System :: POSIXProgramming Language :: PythonProgramming Language :: Python :: 2.7Programming Language :: Python :: 3.10Programming Language :: Python :: 3.11Programming Language :: Python :: 3.12Programming Language :: Python :: 3.13Programming Language :: Python :: 3.5Programming Language :: Python :: 3.6Programming Language :: Python :: 3.7Programming Language :: Python :: 3.8Programming Language :: Python :: 3.9Programming Language :: Python :: Implementation :: CPythonProgramming Language :: Python :: Implementation :: PyPyTopic :: Terminals

Tags

SI prefix formattingIEC binary prefix displaynumber formatting with unitsmetric prefix floatengineering notation formatter
number-formattingsi-iec-prefixes

More Terminals packages