bitmath icon indicating copy to clipboard operation
bitmath copied to clipboard

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

Open beav opened this issue 4 years ago • 0 comments

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.

beav avatar May 11 '20 16:05 beav