Skip to content

Releases: scott-griffiths/bitstring

bitstring-4.2.3

25 May 21:11
Compare
Choose a tag to compare

More small bug fixes related to some of the new (beta) float formats.

  • Some codes representing exotic float negative zero converted to positive zero. Bug #333.
  • Auto-scaling rounding the wrong way on occasion. Bug #334.

bitstring-4.2.2

10 May 19:47
Compare
Choose a tag to compare

A couple more minor bug fixes.

  • Sometimes a ValueError was being raised instead of a ReadError. Bug #325.
  • Initialising a bitstring from None now raises a TypeError rather than generating
    an empty bitstring. Bug #323.
  • Fixed performance regression for find / findall in some situations. Bug #326.
  • Fix for AttributeError bug when combining Bits with BitStream. Bug #329.

bitstring-4.2.1

24 Apr 19:52
Compare
Choose a tag to compare

Fixing a few regressions introduced in 4.2.0.

  • Module crashes on import with 32-bit Python. Bug #317.
  • Lists of integers not converted to bytes when using the bytes constructor. Bug #318.
  • Empty comma separated tokens not handled correctly. Bug #319.
  • Crash on import when docstrings not present due to optimize flag. Bug #321.

bitstring-4.2.0

22 Apr 07:48
Compare
Choose a tag to compare

This release contains a fairly large refactor of how different types are managed. This
shouldn't affect the end user, and the main noticeable change should be the new Dtype
class, which is optional to use.

Support for 8-bit and smaller floats has been reworked and expanded. These are still
a 'beta' feature.

Backwardly incompatible changes:

  • Dropped support for Python 3.7. Minimum version is now 3.8.
  • For tokens that use a non-numeric length, a ':' is now compulsory rather than
    recommended. For example use 'uint:foo' instead of 'uintfoo'.
  • The previous e4m3float and e5m2float formats have become the slightly modified
    p4binary8 and p3binary8 formats.
  • Some parameters are now enforced as positional only, such as auto in constructors.

Other changes:

  • The Array class is no longer 'beta'.

  • A new Dtype class can be optionally used to specify types.

  • The bitstring.options object is now the preferred method for changing module options.
    The bitstring.lsb0 and bitstring.bytealigned variables are now deprecated, use
    bitstring.options.lsb0 and bitstring.options.bytealigned instead.

  • New fromstring method as another way to create bitstrings from formatted strings.
    Instead of relying on the auto parameter you can now optionally use fromstring.

  >>> s1 = BitArray('u24=1000')  # This is still fine
  >>> s2 = BitArray.fromstring('u24=1000')  # This may be clearer and more efficient.
  • More types can now be pretty printed. For example integer and float formats can be used.
  >>> s.pp('u15, bin')
  • Pretty printing is now prettier - optional terminal colours added.

  • A range of 8-bit, 6-bit and even 4-bit float formats added (beta):
    p3binary8: IEEE 8-bit floating point with 3 bit precision.
    p4binary8: IEEE 8-bit floating point with 4 bit precision.
    e5m2mxfp: OCP 8-bit floating point with 3 bit precision.
    e4m3mxfp: OCP 8-bit floating point with 4 bit precision.
    e2m3mxfp: OCP 6-bit floating point with 4 bit precision.
    e3m2mxfp: OCP 6-bit floating point with 3 bit precision.
    e2m1mxfp: OCP 4-bit floating point with 2 bit precision.
    e8m0mxfp: OCP 8-bit unsigned floating point designed to scale the other formats.
    mxint: OCP 8-bit floating point that is a scaled integer representation.

  • Performance improvements.

bitstring-4.1.4

29 Nov 18:18
Compare
Choose a tag to compare

Fixing a regression introduced in 4.1.3

  • 'bytes' token can't be used without explicit length. Bug #303.

bitstring-4.1.3

22 Nov 17:25
Compare
Choose a tag to compare

A maintenance release, with some changes to the beta features introduced in 4.1.

  • Removed a couple of files that accidentally got included in the previous release. Bug #293.
  • The 8-bit float formats have been renamed 'e4m3float' and 'e5m2float'.
  • Some refactoring and performance optimizations.

bitstring-4.1.2

07 Sep 20:19
Compare
Choose a tag to compare

Another maintenance release. Once again some small changes to the 'beta' Array class,
plus new Array functionality.

  • Fix for the module command-line usage. Bug #290.
  • Fix for when creating bitstrings from memoryview objects.
  • Renamed the 'fmt' parameter for Arrays to 'dtype'.
  • More Array operator coverage.
  • Added operators that act on two Arrays of the same size.
  • Added comparison operators for Arrays that return an Array of bools.
  • Added Array.equals method as == will now return an Array (see above item).
  • Added astype() method for Arrays to easily cast to a new dtype.

bitstring-4.1.1

23 Aug 08:55
99cebf0
Compare
Choose a tag to compare

A maintenance release, with some changes to the Array class which is still in 'beta'.

  • bitarray dependency now pinned to ">=2.8.0, <3.0.0" rather than a specific version. Bug #283.
  • Fix for using numpy integers as integer parameters. Bug #286.
  • Removed ability to extend an Array with the '+' operator. Use the 'extend' method instead.
  • Improvements when pretty-printing the Array.
  • Array.count() can now count 'nan' values for floating point types.

bitstring-4.1.0

17 Aug 14:14
Compare
Choose a tag to compare

This has turned into a suprisingly big release, with a major refactor and a brand new
class (the first for 12 years!) There are also a couple of small possibly breaking changes
detailed below, in particular 'auto' initialising bitstrings from integers is now disallowed.

Speed increased with bitarray dependency.

The major weakness of bitstring has been its poor performance for computationally
intensive tasks relative to lower level alternatives. This was principally due to
relying on pure Python code to achieve things that the base language often didn't have
fast ways of doing.

This release starts to address that problem with a fairly extensive rewrite to replace
much of the pure Python low-level bit operations with methods from the bitarray package.
This is a package that does many of the same things as bitstring, and the two packages
have co-existed for a long time. While bitarray doesn't have all of the options and
facilities of bitstring it has the advantage of being very fast as it is implemented in C.
By replacing the internal datatypes I can speed up bitstring's operations while keeping
the same API.

Huge kudos to Ilan Schnell for all his work on bitarray.

New Array class for homogeneous data (beta)

If your data is all of the same type you can make use of the new Array class, which
mirrors much of the functionality of the standard array.array type, but doesn't restrict
you to just a dozen formats.

  >>> from bitstring import Array
  >>> a = Array('uint7', [9, 100, 3, 1])
  >>> a.data
  BitArray('0x1390181')
  >>> b = Array('float16', a.tolist())
  >>> b.append(0.25)
  >>> b.tobytes()
  b'H\x80V@B\x00<\x004\x00'
  >>> b.tolist()
  [9.0, 100.0, 3.0, 1.0, 0.25]

The data is stored efficiently in a BitArray object, and you can manipulate both the
data and the Array format freely. See the main documentation for more details. Note that
this feature carries the 'beta' flag so may change in future point versions.

Other changes:

  • Added two new floating point interpretations: float8_143 and float8_152. These are 8-bit
    floating point formats, with very limited range and precision, but useful in some fields,
    particularly machine learning. This is an experimental feature - the formats haven't
    even been standardised yet.
  >>> a = Bits(float8_143=16.5)
  >>> a.bin
  '01100000'
  >>> a.float8_143
  16.0
  • Auto initialistion from ints has been removed and now raises a TypeError. Creating a
    bitstring from an int still creates a zeroed bitstring of that length but ints won't
    be promoted to bitstrings as that has been a constant source of errors and confusion.
  >>> a = BitArray(100)  # Fine - create with 100 zeroed bits
  >>> a += 0xff   # TypeError - previously this would have appended 0xff (=255) zero bits.
  >>> a += '0xff'  # Probably what was meant - append eight '1' bits.
  >>> a += Bits(255)  # Fine, append 255 zero bits.

This is a breaking change, but it breaks loudly with an exception, it is easily recoded,
and it removes a confusing wrinkle.

  • Explicitly specifying the 'auto' parameter is now disallowed rather than discouraged.
    It was always meant to be a positional-only parameter (and will be once I can drop
    Python 3.7 support) but for now it's renamed to __auto. In the unlikely event
    this breaks code, the fix should be just to delete the auto= if it's already the
    first parameter.
  >>> s = Bits(auto='0xff')  # Now raises a CreationError
  >>> s = Bits('0xff')  # Fine, as always
  • Deleting, replacing or inserting into a bitstring resets the bit position to 0 if the
    bitstring's length has been changed. Previously the bit position was adjusted but
    this was not well defined.

  • Only empty bitstring are now considered False in a boolean sense. Previously s was
    False is no bits in s were set to 1, but this goes against what it means to be a
    container in Python so I consider this to be a bug, even if it was documented. I'm
    guessing it's related to __nonzero__ in Python 2 becoming __bool__ in Python 3, and
    it's never been fixed before now.

  • Casting to bytes now behaves as expected, so that bytes(s) gives the same result as
    s.tobytes(). Previously it created a byte per bit.

  • Pretty printing with the 'bytes' format now uses characters from the 'Latin Extended-A'
    unicode block for non-ASCII and unprintable characters instead of replacing them with '.'

  • When using struct-like codes you can now use '=' instead of '@' to signify native-
    endianness. They behave identically, but the new '=' is now preferred.

  • More fixes for LSB0 mode. There are now no known issues with this feature.

bitstring-4.0.2

16 Apr 13:47
Compare
Choose a tag to compare

A maintenance release.

  • Added py.typed file and converted the module to a package to let mypy find type
    annotations. Bug 248.
  • Fix to shifting operations when using LSB0 mode. Bug 251.
  • A few more fixes for LSB0 mode.
  • Improved LSB0 documentation.
  • Added build-system section to pyproject.toml. Bug 243.
  • Rewrote the walkthrough documentation as a jupyter notebook.
  • Updated the project's logo.