bitstruct
bitstruct copied to clipboard
Interface of the C implementation
In order to have a drop-in replacement of the pure Python implementation please consider to expose the CompiledFormat and CompiledFormatDict classes also in the C implementation.
Also please note that the C implementation seems to be not mentioned in the HTML documentation (e.g. https://bitstruct.readthedocs.io).
It would be nice to have a short note abut the C implementation also in the HTML documentation (analogously to what done on the README.rst).
Why do you need them? I mean, they are normally instantiated by the compile() function, and are not really meant to be instantiated directly by the user.
The documentation has been updated.
The raised exceptions are different in the C and Python implementation as well. Feel free to make them use the same exceptions in a PR.
In my case I have a simple class
class BitStruct(bitstruct.CompiledFormat):
def __init__(self, format: str):
super().__init__(format)
self._format: str = format
@property
def format(self) -> str:
return self._format
that is used to mimic the behaviour of the struct package form the stdlib.
Ok, feel free to submit a PR that exposes those classes. Possibly add a format property/attribute as well to them.