Dear Pythonists, here’s an idea I’ve been wondering about for a long time.
I’ve spent the last 10+ years working for embedded systems, dealing with firmware images, custom communication protocols, safety norms, log analysis, all requiring handling of several CRC values.
I prototyped a bunch of in-house bootloader host programs, realtime communication nodes, and binary log analyzers. Of course, my main language for these activities was Python.
Despite loving it, I quickly found that I had to either roll my own CRC calculators (often non-standard) or use the very few native ones.
There are some third-party libraries on PyPI, all completely different, yet all implementing almost the same ubiquitous CRC algorithm in some form.
Most are written in pure Python, which is very (very!) slow, especially for realtime communication, or when analyzing gigabytes of binary streams coming from development boards.
The ones written in C still require a compiler be available each time an executable has to be given out; this can be a hassle in some companies and departments.
An option was to create a private Cython module, to get both the benefits of a fast imlpementation, and packaging for deployment in our labs.
So, eventually I came to this idea: adding native CRC support to Python itself, as a companion to the existing message digests, i.e. as an hashlib extension module, just like MD5 or SHA-1.
The many third-party attempts at creating CRC libraries, along with its message digest nature, and the rarity of CRC support in current Python, should ring a bell: we need native support for CRC!
In my spare time I’ve already drafted a PEP and a reference implementation (with tests), you can find at my forks (still WIP):
Please provide some feedback, because I’m willing to sumbit the PEP for PR soon.
I haven’t found any other topics about this feature.