No option for "signed or unsigned"
Would you be willing to accept a pullreq for adding functionality to allow either a signed or an unsigned number to be "packed"? There are cases where one would want to pack a number and its sign doesn't matter. For example, if you want to pack the bits 0b11 into 2 bits of a byte and you don't care if the number is treated as "3" or as "-1", there is currently no way to use this package to do so (that I can figure out at least)
The closest I've been able to figure out is to use the unsigned pack format and bitmask the relevant number of bits. However, in addition to the added overhead of doing the bitmask where it's not needed, this strategy doesn't allow for syntax like this:
bitstruct.pack_into('>u1u1u1u1', *arr[:4]))
since you can't bitmask each element of the spread list
I don't have any immediate problem with adding such functionality. Maybe pack('i2i2i1'), where i is for masked integer, which is always unpacked as unsigned?
That sounds great!