Friday, July 3, 2026

Introducing bitvector-modern, a fork of python BitVector

 About 20 years ago, I used Avi Kak's BitVector python library for my AIS work when my work was pure python as can be found in my noaadata package that I haven't done much with in more than a decade. BitVector is an awesome tool for working with arbitrarily long sequences of bits. A lot has happened in the world of python and software engineering since I donated a Makefile and helped with a bit of packaging. I decided to give a quick go at modernizing BitVector, and after about 5 hours of work, I have bitvector-modern. The function of code in BitVector basically the same at this point, but I've changed a lot that should make maintaining and using the BitVector class a lot easier. 

You can find the work here:

Here are roughly the changes I've made so far with the help of Google Antigravity:

  • Switch to using uv and for pyproject.toml packaging
  • Setup github CI
  • Switched to supporting only Python 3.13 and 3.14 (Was python 2 and 3.6)
  • Use ruff for code formatting
  • Use pytest test discovery
  • Setup code coverage reporting
  • Rename directories to "examples" and "tests"
  • Get set coverage from 40% to 97%
  • Remove extra documentation and tests from BitVector.py
  • Remove unused _resize_pad_from_right method
  • Remove backward compatibility aliases
  • Use pyupgrade to get to 3.13
  • Inline the testinput text files.
  • Uncomment the proposed improved __add__ method and new __iadd__ method
  • Setup astral-sh/ty type checking and add type annotations. There are still lots of "Any" and "..."
  • Switch BitVector.__init__ from kwargs to explicitly named args
  • Setup Dependabot
That leaves a lot more to do, but it's a big start! Some of what I'd like to do:
  • Add an AGENTS.md
  • Convert the prior documentation into a docs directory
  • Convert more string formatting to f-string
  • Convert the method doc strings to a more standard format with summary line, args, returns/yields, raises
  • Cleanup the code inside methods
  • Modernize the iterator using "yield from"
  • Tighten the type annotations
  • Allow pathlib.Path file references
  • Replace deep_copy with python’s
  • Fix the interface to set_value
  • Use a better random number generator than python's random package
  • Setup releases on github
  • Add the package to PyPI
After that, I need to modernize noaadata and get it using bitvector-modern.

No comments:

Post a Comment