Skip to content

Releases: scott-griffiths/bitstring

bitstring-1.3.0

23 Jun 17:54
Compare
Choose a tag to compare

March 18th 2010: version 1.3.0 for Python 2.6 and 3.x released

New features:

  • byteswap method for changing endianness.

Changes the endianness in-place according to a format string or
integer(s) giving the byte pattern. See the manual for details.

>>> s = BitString('0x00112233445566')
>>> s.byteswap(2)
3
>>> s
BitString('0x11003322554466')
>>> s.byteswap('h')
3
>>> s
BitString('0x00112233445566')
>>> s.byteswap([2, 5])
1
>>> s
BitString('0x11006655443322')
  • Multiplicative factors in bitstring creation and reading.

For example:

>>> s = Bits('100*0x123')
  • Token grouping using parenthesis.

For example:

>>> s = Bits('3*(uint:6=3, 0b1)')
  • Negative slice indices allowed.

The start and end parameters of many methods may now be negative, with the
same meaning as for negative slice indices. Affects all methods with these
parameters.

  • Sequence ABCs used.

The Bits class now derives from collections.Sequence, while the BitString
class derives from collections.MutableSequence.

  • Keywords allowed in readlist, peeklist and unpack.

Keywords for token lengths are now permitted when reading. So for example,
you can write

>>> s = bitstring.pack('4*(uint:n)', 2, 3, 4, 5, n=7)
>>> s.unpack('4*(uint:n)', n=7)
[2, 3, 4, 5]
  • start and end parameters added to rol and ror.
  • join function accepts other iterables.

Also its parameter has changed from 'bitstringlist' to 'sequence'. This is
technically a backward incompatibility in the unlikely event that you are
referring to the parameter by name.

  • init method accepts keywords.

Rather than a long list of initialisers the init methods now use a
**kwargs dictionary for all initialisers except 'auto'. This should have no
effect, except that this is a small backward incompatibility if you use
positional arguments when initialising with anything other than auto
(which would be rather unusual).

  • More optimisations.
  • Bug fixed in replace method (it could fail if start != 0).