Skip to content

Releases: scott-griffiths/bitstring

bitstring-3.1.2

23 Jun 10:01
Compare
Choose a tag to compare

April 18th 2013: version 3.1.2 released

This is another bug fix release.

  • Fix for problem where unpacking bytes would by eight times too long

bitstring.3.1.1

23 Jun 10:01
Compare
Choose a tag to compare

March 21st 2013: version 3.1.1 released

This is a bug fix release.

  • Fix for problem where concatenating bitstrings sometimes modified method's arguments

bitstring-3.1.0

23 Jun 10:02
Compare
Choose a tag to compare

February 26th 2013: version 3.1.0 released

This is a minor release with a couple of new features and some bug fixes.

New 'pad' token

This token can be used in reads and when packing/unpacking to indicate that
you don't care about the contents of these bits. Any padding bits will just
be skipped over when reading/unpacking or zero-filled when packing.

>>> a, b = s.readlist('pad:5, uint:3, pad:1, uint:3')

Here only two items are returned in the list - the padding bits are ignored.

New clear and copy convenience methods

These methods have been introduced in Python 3.3 for lists and bytearrays,
as more obvious ways of clearing and copying, and we mirror that change here.

t = s.copy() is equivalent to t = s[:], and s.clear() is equivalent to del s[:].

Other changes

  • Some bug fixes.

bitstring-3.0.2b

23 Jun 10:02
Compare
Choose a tag to compare

February 7th 2012: version 3.0.2 released

This is a minor update that fixes a few bugs.

  • Fix for subclasses of bitstring classes behaving strangely (Issue 121).
  • Fix for excessive memory usage in rare cases (Issue 120).
  • Fixes for slicing edge cases.

There has also been a reorganisation of the code to return it to a single
'bitstring.py' file rather than the package that has been used for the past
several releases. This change shouldn't affect users directly.

bitstring-3.0.1

23 Jun 10:02
Compare
Choose a tag to compare

November 21st 2011: version 3.0.1 released

This release fixed a small but very visible bug in bitstring printing.

bitstring-3.0.0

23 Jun 10:03
Compare
Choose a tag to compare

November 21st 2011: version 3.0.0 released

This is a major release which breaks backward compatibility in a few places.

Backwardly incompatible changes

Hex, oct and bin properties don't have leading 0x, 0o and 0b

If you ask for the hex, octal or binary representations of a bitstring then
they will no longer be prefixed with 0x, 0o or 0b. This was done as it
was noticed that the first thing a lot of user code does after getting these
representations was to cut off the first two characters before further
processing.

>>> a = BitArray('0x123')
>>> a.hex, a.oct, a.bin
('123', '0443', '000100100011')

Previously this would have returned ('0x123', '0o0443', '0b000100100011')

This change might require some recoding, but it should all be simplifications.

ConstBitArray renamed to Bits

Previously Bits was an alias for ConstBitStream (for backward compatibility).
This has now changed so that Bits and BitArray loosely correspond to the
built-in types bytes and bytearray.

If you were using streaming/reading methods on a Bits object then you will
have to change it to a ConstBitStream.

The ConstBitArray name is kept as an alias for Bits.

Stepping in slices has conventional meaning

The step parameter in __getitem__, __setitem__ and __delitem__ used to act
as a multiplier for the start and stop parameters. No one seemed to use it
though and so it has now reverted to the conventional meaning for containers.

If you are using step then recoding is simple: s[a:b:c] becomes s[a*c:b*c].

Some examples of the new usage:

>>> s = BitArray('0x0000')
s[::4] = [1, 1, 1, 1]
>>> s.hex
'8888'
>>> del s[8::2]
>>> s.hex
'880'

New features

New readto method

This method is a mix between a find and a read - it searches for a bitstring
and then reads up to and including it. For example:

>>> s = ConstBitStream('0x47000102034704050647')
>>> s.readto('0x47', bytealigned=True)
BitStream('0x47')
>>> s.readto('0x47', bytealigned=True)
BitStream('0x0001020347')
>>> s.readto('0x47', bytealigned=True)
BitStream('0x04050647')

pack function accepts an iterable as its format

Previously only a string was accepted as the format in the pack function.
This was an oversight as it broke the symmetry between pack and unpack.
Now you can use formats like this:

fmt = ['hex:8', 'bin:3']
a = pack(fmt, '47', '001')
a.unpack(fmt)

bitstring-2.2.0

23 Jun 10:04
Compare
Choose a tag to compare

June 18th 2011: version 2.2.0 released

This is a minor upgrade with a couple of new features.

New interleaved exponential-Golomb interpretations

New bit interpretations for interleaved exponential-Golomb (as used in the
Dirac video codec) are supplied via 'uie' and 'sie':

>>> s = BitArray(uie=41)
>>> s.uie
41
>>> s.bin
'0b00010001001'

These are pretty similar to the non-interleaved versions - see the manual
for more details. Credit goes to Paul Sargent for the patch.

New package-level bytealigned variable

A number of methods take a 'bytealigned' parameter to indicate that they
should only work on byte boundaries (e.g. find, replace, split). Previously
this parameter defaulted to 'False'. Instead it now defaults to
'bitstring.bytealigned', which itself defaults to 'False', but can be changed
to modify the default behaviour of the methods. For example:

>>> a = BitArray('0x00 ff 0f ff')
>>> a.find('0x0f')
(4,)    # found first not on a byte boundary
>>> a.find('0x0f', bytealigned=True)
(16,)   # forced looking only on byte boundaries
>>> bitstring.bytealigned = True  # Change default behaviour
>>> a.find('0x0f')
(16,)
>>> a.find('0x0f', bytealigned=False)
(4,)

If you're only working with bytes then this can help avoid some errors and
save some typing!

Other changes

  • Fix for Python 3.2, correcting for a change to the binascii module.
  • Fix for bool initialisation from 0 or 1.
  • Efficiency improvements, including interning strategy.

bitstring-2.1.1

23 Jun 10:04
Compare
Choose a tag to compare

February 23rd 2011: version 2.1.1 released

This is a release to fix a couple of bugs that were introduced in 2.1.0.

  • Bug fix: Reading using the 'bytes' token had been broken (Issue 102).
  • Fixed problem using some methods on ConstBitArrays.
  • Better exception handling for tokens missing values.
  • Some performance improvements.

bitstring-2.1.0

23 Jun 10:05
Compare
Choose a tag to compare

January 23rd 2011: version 2.1.0 released

New class hierarchy introduced with simpler classes

Previously there were just two classes, the immutable Bits which was the base
class for the mutable BitString class. Both of these classes have the concept
of a bit position, from which reads etc. take place so that the bitstring could
be treated as if it were a file or stream.

Two simpler classes have now been added which are purely bit containers and
don't have a bit position. These are called ConstBitArray and BitArray. As you
can guess the former is an immutable version of the latter.

The other classes have also been renamed to better reflect their capabilities.
Instead of BitString you can use BitStream, and instead of Bits you can use
ConstBitStream. The old names are kept as aliases for backward compatibility.

The classes hierarchy is:

    ConstBitArray
       /    \
      /      \
BitArray   ConstBitStream (formerly Bits)
      \      /
       \    /
      BitStream (formerly BitString)

Other changes

A lot of internal reorganisation has taken place since the previous version,
most of which won't be noticed by the end user. Some things you might see are:

  • New package structure. Previous versions have been a single file for the
    module and another for the unit tests. The module is now split into many
    more files so it can't be used just by copying bitstring.py any more.
  • To run the unit tests there is now a script called runtests.py in the test
    directory.
  • File based bitstring are now implemented in terms of an mmap. This should
    be just an implementation detail, but unfortunately for 32-bit versions of
    Python this creates a limit of 4GB on the files that can be used. The work
    around is either to get a 64-bit Python, or just stick with version 2.0.
  • The ConstBitArray and ConstBitStream classes no longer copy byte data when
    a slice or a read takes place, they just take a reference. This is mostly
    a very nice optimisation, but there are occassions where it could have an
    adverse effect. For example if a very large bitstring is created, a small
    slice taken and the original deleted. The byte data from the large
    bitstring would still be retained in memory.
  • Optimisations. Once again this version should be faster than the last.
    The module is still pure Python but some of the reorganisation was to make
    it more feasible to put some of the code into Cython or similar, so
    hopefully more speed will be on the way.

bitstring-2.0.3

23 Jun 10:05
Compare
Choose a tag to compare

July 26th 2010: version 2.0.3 released

  • Bug fix: Using peek and read for a single bit now returns a new bitstring
    as was intended, rather than the old behaviour of returning a bool.
  • Removed HTML docs from source archive - better to use the online version.