Millify

0.1.1 · active · verified Fri Apr 17

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.

Common errors

Warnings

Install

Imports

Quickstart

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)}")

view raw JSON →