Bit substring search

Kris Kennaway kris at FreeBSD.org
Tue Jun 24 15:51:53 CEST 2008


bearophileHUGS at lycos.com wrote:
> Kris Kennaway:
>> I am trying to parse a bit-stream file format (bzip2) that does not have
>> byte-aligned record boundaries, so I need to do efficient matching of
>> bit substrings at arbitrary bit offsets.
>> Is there a package that can do this?
> 
> You may take a look at Hachoir or some other modules:
> http://hachoir.org/wiki/hachoir-core
> http://pypi.python.org/pypi/construct/2.00

Thanks.  hachoir also comes close, but it also doesnt seem to be able to 
match substrings at a bit level (e.g. the included bzip2 parser just 
reads the header and hands the entire file off to libbzip2 to extract 
data from).

construct exports a bit stream but it's again pure python and matching 
substrings will be slow.  It will need C support to do that efficiently.

> http://pypi.python.org/pypi/FmtRW/20040603
> Etc. More:
> http://pypi.python.org/pypi?%3Aaction=search&term=binary

Unfortunately I didnt find anything else useful here yet :(

Kris




More information about the Python-list mailing list