Transition to 2.9


Construct is undergoing heavy changes at the moment, expect unstable API for about a month.


Compilation feature for faster performance! Read this tutorial chapter, particularly its restrictions section.

Docstrings of all classes were overhauled. Check the Core API pages.

General classes

All constructs: parse build sizeof methods take context entries ONLY as keyword parameters **kw (see tutorial page)

All constructs: compile benchmark testcompiled methods were added (see tutorial page)

All constructs: operator * can be used for docstrings (see tutorial page)

Compiled CompilableMacro Decompiled added (used internally)

String* require explicit encodings, all of them support UTF16 UTF32 encodings, but String CString dropped some parameters and support only encodings explicitly listed in possiblestringencodings (see tutorial page)

String* build empty strings into empty bytes (despite for example UTF16 encoding empty string into 2 bytes marker)

Enum FlagsEnum can merge labels from IntEnum IntFlag, from enum34 module (see tutorial page)

Enum FlagsEnum dropped default parameter but returns integer if no mapping found (see tutorial page)

Enum FlagsEnum can build from integers and labels, and expose labels as attributes as bitwisable strings (see tutorial page)

Mapping replaced SymmetricMapping, and dropped default parameter (see API page)

Struct Sequence Union FocusedSeq have new embedding semantics (see tutorial page)

Struct Sequence Union FocusedSeq are exposing subcons in context (see tutorial page)

EmbeddedBitStruct removed

Array reimplemented without Range, does not use stream.tell()

Range removed, GreedyRange remains

Const has reordered parameters, like Const(b"\\x00") and Const(0, Int8ub). (see API page)

Index added, in Miscellaneous (see tutorial page)

Pickled added, in Miscellaneous (see tutorial page)

Timestamp added, in Miscellaneous (see tutorial page)

Hex HexDump reimplemented (see tutorial page)

If IfThenElse parameter renamed predicate to condfunc, and cannot be embedded (see API page)

Switch dropped includekey parameter, and cannot be embedded (see API page)

EmbeddedSwitch added, in Conditional (see tutorial page)

RestreamData added, in Tunneling (see tutorial page)

TransformData added, in Tunneling (see tutorial page)

ExprAdapter Mapping Restreamed changed parameters order (decoders before encoders)

Adapter changed parameters, added path to _encode _decode _validate

LazyStruct LazySequence LazyRange LazyField(OnDemand) removed

LazyBound remains, but changed to parameter-less lambda (see tutorial page)

FlagsContainer removed

HexString removed


FieldError was replaced with StreamError (raised when stream returns less than requested amount) and FormatFieldError (raised by FormatField class, for example if building Float from non-float value and struct.pack complains).

StreamError can be raised by most classes, when the stream is not seekable or tellable

StringError can be raised by most classes, when expected bytes but given unicode value

BitIntegerError was replaced with IntegerError

Struct Sequence can raise IndexError KeyError when dictionaries are missing entries

RepeatError added

IndexFieldError added

CheckError added

NamedTupleError added

RawCopyError added