Skip to content

display "B" instead of "Byte" when creating strings #93

@beav

Description

@beav

Howdy!

Right now, most strings use abbreviations. However, "Byte" is still written out all the way. This can cause consistency issues. For example:

import bitmath

with bitmath.format(fmt_str="{value:.2f} {unit}"):
    formatted_size = bitmath.Byte(500).best_prefix()
    print(str(formatted_size))

    formatted_size = bitmath.Byte(2**25).best_prefix()
    print(str(formatted_size))

    formatted_size = bitmath.Byte(2**37).best_prefix()
    print(str(formatted_size))

results in:

500.00 Byte
32.00 MiB
128.00 GiB

I can set format_plural to make Byte pluralized, but this also pluralizes everything else:

500.00 Bytes
32.00 MiBs
128.00 GiBs

Would it be possible to use B instead of Byte? I think this would make everything match up. It should be ok to use B per https://en.wikipedia.org/wiki/IEEE_1541-2002.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions