It’s been quite a while since I’ve posted any bitmath updates (bitmath is a Python module I wrote which simplifies many facets of interacting with file sizes in various units as python objects) . In fact, it seems that the last time I wrote about bitmath here was back in 2014 when 1.0.8 was released! So here is an update covering everything post 1.0.8 up to 1.3.0.

New Features

  • A command line tool, bitmath, you can use to do simple conversions right in your shell [docs]!

  • New utility function bitmath.parse_string for parsing a human-readable string into a bitmath object

  • New utility: argparse integration: bitmath.BitmathType. Allows you to specify arguments as bitmath types

  • New utility: progressbar integration: bitmath.integrations.BitmathFileTransferSpeed. A more functional file transfer speed widget

  • New bitmath module function: bitmath.query_device_capacity(). Create bitmath.Byte instances representing the capacity of a block device

    • This my favorite enhancement

    • In an upcoming  blog post I’ll talk about just how cool I thought it was learning how to code this feature

    • Conceptual and practical implementation topics included

  • The bitmath.parse_string() function now can parse ‘octet’ based units

  • New utility function: bitmath.best_prefix()

    • Return an equivalent instance which uses the best human-readable prefix-unit to represent it

    • This is way cooler than it may sound at the surface, I promise you

Bug Fixes

  • #49 - Fix handling unicode input in the bitmath.parse_string function. Thanks drewbrew!

  • #50 - Update the script to be python3.x compat. Thanks ssut!

  • #55 “best_prefix for negative values”. Now bitmath.best_prefix() returns correct prefix units for negative values. Thanks mbdm!


To help with the Fedora Python3 Porting project, bitmath now comes in two variants in Fedora/EPEL repositories (BZ1282560). The Fedora and EPEL updates are now in the repos. TIP: python2-bitmath will obsolete the python-bitmath package. Do a dnf/yumupdate’ operation just to make sure you catch it.

The PyPi release has already been pushed to stable.

Back in bitmath-1.0.8 we had 150 unit tests. The latest release has almost 200! Go testing! :confetti: