bitstring 2.0 released

Scott Griffiths dr.scottgriffiths at
Wed Jul 28 22:54:44 CEST 2010

I'm pleased to announce the release of version 2.0 of the bitstring

What is it?

bitstring helps to make creating, manipulating and deconstructing
data as easy as possible. It allows arbitrary (and very large) bit
to be used without worrying about bit shifting and masking operations.
The comprehensive API covers packing, reading, searching, replacing
slicing as well as bit setting and checking, a host of different
interpretations and all the standard bit-wise operators.

The module is pure Python and is available for Python 2.6 and later,
including Python 3.

What's new in version 2?

The main change is a more powerful and streamlined API. Too much to go
here (see the release notes), but here are some simple examples:

>>> s = BitString('0x000001b3')  # create a 32-bit bitstring from hexadecimal
>>> s += 'uint:12=352, uint:12=288'  # append two 12-bit integers
>>> s += bitstring.pack('<2f, 0b1, <h', 0.1, 3.7, 44)  # pack more values
>>> s.unpack('hex:32, 2*uint:12, <2f, bool, <h')  # unpack it all
['0x000001b3', 352, 288, 0.10000000149011612, 3.700000047683716, True,
>>> s.tobytes()              # convert to bytes
b'\x00\x00\x01\xb3\x16\x01 \xcd\xcc\xcc=\xcd\xccl@\x96\x00\x00'
>>> t = s[32:41].            # slicing
>>> t.bin                    # the binary interpretation
>>> list(t.findall('0b10'))  # finding bit patterns
[3, 6]

Where can I find out more?

The project's homepage is at

Documentation is hosted at

Release note for all versions:



Scott Griffiths

More information about the Python-announce-list mailing list