Skip to main content

Module byte_format

Module byte_format 

Source
Expand description

Human-readable byte-size formatting.

Sizes are decimal (4.9 GB is 4.9e9 bytes, not 4.9 GiB), which is how the hubs and a model’s own page state them; memory is binary and keeps its own GiB figures through the constants below.

Constants§

BYTES_PER_GIB
Bytes in one gibibyte, for memory figures.
BYTES_PER_MIB
Bytes in one mebibyte, for the memory figures budgeted in them.

Functions§

format_bytes
Format a byte count as a short human string (B/KB/MB/GB). Gigabytes get one decimal place, with a trailing .0 trimmed.
one_decimal
value with one decimal place, a trailing .0 trimmed: 4.7, 64.