Support for bits in the Buffer Protocol

PEP 3118 makes mention of adding bits to the struct syntax among a few other types. I’ve read through other discussions on the topic that would seemingly confirm bits are not implemented, but I couldn’t find anything that mentioned the bits addition specifically, just note that a lot of the other types may be hard or impossible to implement.

Is there any discussions that go over the merits of the bits addition? Or if not is there an appropriate channel to restart that conversation?

As background I’ve been exploring the use of bitmask backed arrays in pandas. pandas uses Cython typed memoryviews in many places to access existing uint8_t masks (which are exclusively NumPy arrays). As such there are a lot of cases where we seemingly have to convert our bitmasks into bytemasks to appease the buffer protocol, which would be great to avoid from a time/space perspective. The Arrow C++ / Python implementations also use a bitmask, so I think there could be a good use case for bit buffer interoperability

1 Like