Reading a Bitstream

Dietrich Epp dietrich at zdome.net
Wed Nov 19 21:02:42 EST 2003


On Nov 19, 2003, at 7:02 PM, Bengt Richter wrote:

[snip]

> Maybe this will do something for you?
> Note that this is a response to your post, and not something 
> previously tested,
> (in fact not tested beyond what you see ;-) and it will be slow if you 
> have
> huge amounts of data to process.
>
> You pass a string to the constructor, specifying big-endian if not 
> little-endian,
> and then you use the read method to read bit fields, which may 
> optionally have
> their most significant bits interpreted as sign bits.
>
> E.g., reading 4-bit chunks or bits, little-endian and big-endian:

[snip]

It looks like what I did before I started using struct.unpack.  I think 
I'll stick with my current code, which, although it looks like ugly C 
code, works.  Someday I'll probably get the itch again and make a 
decent module out of it.






More information about the Python-list mailing list