Hurry Filesize

0.9 · maintenance · verified Mon Apr 13

Hurry Filesize is a simple Python library, version 0.9, designed to convert a number of bytes into a human-readable string (e.g., '1K', '2M'). First released in 2009, it provides various systems for formatting, including traditional (1024 multipliers), SI (1000 multipliers), and verbose options. Due to its age, it maintains a very low release cadence, with its current version being its initial public release.

Warnings

Install

Imports

Quickstart

This quickstart demonstrates how to import and use the `size` function with its default 'traditional' system and alternative formatting systems (alternative, SI, verbose) to convert byte values into human-readable strings.

from hurry.filesize import size, alternative, si, verbose

bytes_value = 1024 * 1024 * 3.5 # 3.5 MB

print(f"Default: {size(bytes_value)}")
print(f"Alternative: {size(bytes_value, system=alternative)}")
print(f"SI: {size(bytes_value, system=si)}")
print(f"Verbose: {size(bytes_value, system=verbose)}")

# Example with smaller values
print(f"10 bytes (default): {size(10)}")
print(f"10 bytes (alternative): {size(10, system=alternative)}")
print(f"10 bytes (verbose): {size(10, system=verbose)}")

view raw JSON →