Registry / serialization / millify

millify

JSON →
library0.1.1pypypi✓ verified 85d ago

Millify is a lightweight Python library designed to convert large numbers into human-readable, "millified" formats, similar to how social media platforms display follower counts (e.g., 1,234,567 becomes 1.23M). It currently stands at version 0.1.1 and has a relatively slow release cadence, with updates focused on minor improvements and bug fixes.

pip install millify
INSTALL
IMPORT
SIG · MILLIFY
M
millify
serializationpythonv0.1.1
Install
2.4s avg
Import
5ms
Disk
17MB
Pass rate
10/ 10
Env Coverage10 / 10
glibc
3.93.13
musl
3.93.13
Install & Compatibility
Where this runs
tested against v0.1.1 · pip install
no network on importno background threads
Install × environment matrix
Each cell = how many times install + import succeeded across repeated harness runs. Partial = flaky.
glibc = Debian/Ubuntu slim · musl = Alpine Linux
musl
py 3.103.910 runs
installs and imports cleanly · install 0.0s · import 0.001s · 19.2MB
glibc
py 3.103.910 runs
installs and imports cleanly · install 2.4s · import 0.000s · 20MB
17MB installed
● package 17MB
Code
Verified usage

Verified import paths — ran on the pinned version, not inferred.

millify
from millify import millify

Demonstrates the basic usage of the `millify` function to convert numbers, including setting precision, specifying decimal places, and using custom prefixes for different scaling requirements.

from millify import millify # Basic usage: 1,234,567 -> 1.23M print(f"Default: {millify(1234567)}") # With specified precision: 987,654,321 -> 988M (3 significant digits) print(f"Precision=3: {millify(987654321, precision=3)}") # With specified decimal places: 5,000,000,000 -> 5.0B print(f"Decimal places=1: {millify(5000000000, decimal_places=1)}") # Custom prefixes for different scales (e.g., 'K' for 10^3, 'M' for 10^6, 'G' for 10^9) print(f"Custom prefixes: {millify(1024 * 1024 * 5, prefixes=['', 'KB', 'MB', 'GB'], decimal_places=2)}")
Debug
Known issues
gotchaWhen both `precision` and `decimal_places` are provided to the `millify` function, `decimal_places` will take precedence, overriding the `precision` setting.
fix
Choose either `precision` for significant digits or `decimal_places` for digits after the decimal point based on desired behavior. Do not use both simultaneously unless you intend `decimal_places` to override.
affects: 0.1.x
gotchaThe default prefixes (K, M, B, T for thousands, millions, billions, trillions) are based on standard SI units. For contexts requiring different scales or binary prefixes (e.g., KiB, MiB for computing), custom prefixes must be explicitly provided.
fix
Pass a list of custom prefixes using the `prefixes` argument (e.g., `prefixes=['', 'KB', 'MB', 'GB']`) to match your specific domain requirements.
affects: 0.1.x
gotchaBy default, `drop_zeros=True`, meaning trailing zeros after the decimal point will be removed (e.g., `1.0M` becomes `1M`). If you need to always show a specific number of decimal places, including trailing zeros, this default behavior might be unexpected.
fix
Set `drop_zeros=False` in the `millify` function call to retain trailing zeros after the decimal point.
affects: 0.1.x
Errors
Common errors & fixes
TypeError: 'int' object is not subscriptable
The input value passed to the `millify` function was not a number (e.g., a string, list, or None).
fix
Ensure the value passed to `millify` is an integer or a float.
My number isn't displaying the right number of decimal places even with precision set.
This is often due to `decimal_places` being set simultaneously (which overrides `precision`), or `drop_zeros=True` (the default) removing trailing zeros.
fix
Remove the `decimal_places` argument if you are using `precision`. If you need to keep trailing zeros, set `drop_zeros=False`.
Upgrade
Version history
0.1.1latest on PyPI · released Jan 15, 2018
Audit
Dependencies
pythonrequiredRequires Python 3.7 or higher.
Agent activity
3 hits · last 30 days
node
2
Amazon
1
Resources
millify — pip install millify · libregistry