Skip to content

Equivalents to struct.calcsize() and struct.iter_unpack()? #316

Discussion options

You must be logged in to vote

Hi. Those are both very good questions.

For the first part, It would be easier to use pack to create a dummy bitstring and just measure the length of that. You would need to know how many values to pack (and their types) but it's slightly less horrible?

In general however there is no way to do a calcsize as the length of some data types depends on their values - in particular you don't know how long exponential-Golomb codes are going to be until you read them. There is room for a method for when it is possible though, and I think it's a good idea. I've recently started work on a new project called bitformat where this sort of thing would be easy. Possibly I could port that new functionali…

Replies: 2 comments 2 replies

Comment options

You must be logged in to vote
2 replies
@JamesTheAwesomeDude
Comment options

@scott-griffiths
Comment options

Answer selected by JamesTheAwesomeDude
Comment options

You must be logged in to vote
0 replies
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Q&A
2 participants