{"id":5375,"library":"prefixed","title":"Prefixed alternative numeric library","description":"Prefixed provides an alternative implementation of the built-in `float` which supports formatted output with SI (decimal) and IEC (binary) prefixes. The library is actively maintained with regular updates addressing bug fixes, new SI prefixes, and improvements to string parsing and formatting behavior.","status":"active","version":"0.9.0","language":"en","source_language":"en","source_url":"https://github.com/Rockhopper-Technologies/prefixed","tags":["numeric","units","scientific","engineering","formatting","f-string","si-units","iec-units"],"install":[{"cmd":"pip install prefixed","lang":"bash","label":"Install latest version"}],"dependencies":[{"reason":"Core runtime dependency; the library is implemented in Python.","package":"python","optional":false}],"imports":[{"symbol":"Float","correct":"from prefixed import Float"}],"quickstart":{"code":"from prefixed import Float\n\n# Basic SI formatting\nvalue_si = Float(3250)\nprint(f'{value_si:.2h}')\n\n# IEC formatting with bytes unit\nvalue_iec = Float(42467328)\nprint(f'{value_iec:.2k}B')\n\n# Significant digits with SI\nvalue_sig_dig = Float(1246)\nprint(f'{value_sig_dig:.3H}')\n\n# Initializing from strings with prefixes\nfrom_string_k = Float('2k')\nfrom_string_Ki = Float('2Ki')\nprint(f'{from_string_k=}')\nprint(f'{from_string_Ki=}')","lang":"python","description":"Initialize `prefixed.Float` objects and format them using f-strings with SI ('h', 'H') or IEC ('k', 'K', 'm', 'M') prefixes. Precision can indicate significant digits for 'H', 'K', 'M' types. String initialization also recognizes SI and IEC prefixes."},"warnings":[{"fix":"Review usage of `!` flag. If you relied on the space being dropped when no prefix was present, switch to using `!!`. Otherwise, no action is needed, as `!` now consistently adds a space.","message":"The behavior of the `!` format flag changed in version 0.6.0. Previously, `!` would drop the space after the number if no prefix was added. It now consistently adds a space after the number, even if no prefix is present. A new `!!` flag was introduced for the old behavior (dropping the space if no prefix is added).","severity":"breaking","affected_versions":"0.6.0+"},{"fix":"Replace 'j' with 'k' and 'J' with 'm' in your format strings.","message":"The format specifiers 'j' (IEC) and 'J' (IEC short) were deprecated in version 0.4.0. They have been replaced by 'k' and 'm' respectively. While 'j' and 'J' still work, their use is discouraged and may be removed in future versions.","severity":"deprecated","affected_versions":"0.4.0+"},{"fix":"Ensure input strings adhere to the format of a number followed by an optional single space, then an optional prefix (e.g., '10 k', '500m', '2Ki').","message":"Input string parsing became stricter in version 0.3.2. It no longer accepts arbitrary characters after the prefix and now specifically allows a single space between the value and the prefix. If your application relied on less strict parsing for `Float` initialization from strings, it might break.","severity":"gotcha","affected_versions":"0.3.2+"},{"fix":"Upgrade to version 0.8.0 or later to ensure correct rounding behavior during prefix determination.","message":"Prior to version 0.8.0, rounding was not correctly accounted for when determining the appropriate prefix, leading to inaccurate results (e.g., `9.999999999e-10` formatting as `1000p` instead of `1n`). This was corrected in 0.8.0.","severity":"gotcha","affected_versions":"<0.8.0"},{"fix":"Be aware of this input/output distinction if your application processes or expects specific Unicode representations of the micro prefix.","message":"As of version 0.9.0, the micro symbol ('µ', U+00B5) is accepted as a valid prefix when creating `prefixed.Float` objects from strings. However, the output will still consistently use the lowercase Greek letter mu ('μ', U+03BC).","severity":"gotcha","affected_versions":"0.9.0+"}],"env_vars":null,"last_verified":"2026-04-13T00:00:00.000Z","next_check":"2026-07-12T00:00:00.000Z"}