It's always been a bit strange that pack creates a BitStream object, when they're probably the least used type.
So instead of
a = bitstring.pack('...')
we can say
a = bitstring.BitStream.pack('...')
b = bitstring.Bits.pack('...')
etc.
and they'll return the expected type. These would be class methods rather than the module method currently in use.
No need to remove the current way though, so can remain backwardly compatible.
That does raise the question of other classmethod constructors. The current way probably isn't the most Pythonic, but there are a lot of constructors. I mean we could implement these:
a = Bits.from_int(14, length=9)
b = BitArray.from_float(0.2, length=32, endianness='little')
c = BitStream.from_bytes(b'123', offset=4, length=15)
etc., etc.
but I don't think that would be helpful at this stage.
It's always been a bit strange that pack creates a BitStream object, when they're probably the least used type.
So instead of
we can say
and they'll return the expected type. These would be class methods rather than the module method currently in use.
No need to remove the current way though, so can remain backwardly compatible.
That does raise the question of other classmethod constructors. The current way probably isn't the most Pythonic, but there are a lot of constructors. I mean we could implement these:
but I don't think that would be helpful at this stage.