BitStream¶
- class BitStream(auto: BitsType | int | None, /, length: int | None = None, offset: int | None = None, pos: int = 0, **kwargs)¶
Both the
BitArrayand theConstBitStreamclasses are base classes forBitStreamand so all of their methods are also available forBitStreamobjects. The initialiser is the same as forConstBitStream.A
BitStreamis 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,BitArrayandConstBitStream) 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) theposwill move to the end of the bitstring.If a method otherwise changes the length of the bitstring (
prepend,insert, sometimesreplace) theposbecomes invalid and will be reset to0.