BitStream¶
- class BitStream(auto: BitsType | int | None, /, length: int | None = None, offset: int | None = None, pos: int = 0, **kwargs)¶
Both the
BitArray
and theConstBitStream
classes are base classes forBitStream
and so all of their methods are also available forBitStream
objects. The initialiser is the same as forConstBitStream
.A
BitStream
is a mutable container of bits with methods and properties that allow it to be parsed as a stream of bits. There are no additional methods or properties in this class - see its base classes (Bits
,BitArray
andConstBitStream
) for details.
The pos
will also used as a default for the BitArray.overwrite
and BitArray.insert
methods.
The bit position is modified by methods that read bits, as described in pos
, but for the mutable BitStream
it is also modified by other methods:
If a methods extends the bitstring (
+=
,append
) thepos
will move to the end of the bitstring.If a method otherwise changes the length of the bitstring (
prepend
,insert
, sometimesreplace
) thepos
becomes invalid and will be reset to0
.