Skip to content

IEC (binary) or SI (decimal)#223

Open
WhiteSymmetry wants to merge 4 commits intoworkhorsy:masterfrom
K-Class:master
Open

IEC (binary) or SI (decimal)#223
WhiteSymmetry wants to merge 4 commits intoworkhorsy:masterfrom
K-Class:master

Conversation

@WhiteSymmetry
Copy link
Copy Markdown

Summary of Changes

  • Added _to_friendly_bytes function

    • Converts raw byte values into human‑readable formats (e.g., 1024000999 KiB or 1 MB).
    • Supports both SI units (KB, MB, GB, TB) and IEC binary units (KiB, MiB, GiB, TiB).
    • Uses regex patterns to detect the unit suffix and formats the output accordingly.
  • Added _friendly_bytes_to_int function

    • Parses strings like "2TB", "1TiB", "500MB", "500MiB" and converts them back into integer byte values.
    • Correctly distinguishes between decimal (1000‑based) and binary (1024‑based) multipliers.
    • Handles short forms (T, G, M, K, B) as well as full unit names.
  • Integration with cpuinfo.get_cpu_info() output

    • Cache sizes and line sizes returned as raw integers can now be passed through _to_friendly_bytes.
    • This allows displaying CPU cache information in a consistent, human‑friendly format (KB, KiB, MB, MiB, etc.) instead of plain byte counts.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant