Changelog

Release Notifications

Follow on Sibbell

Tip: Follow bidict on Sibbell to be notified when a new version of bidict is released.

0.14.0 (2017-11-20)

  • Fix a bug where bidict‘s default on_dup_kv policy was set to RAISE, rather than matching whatever on_dup_val policy was in effect as was documented.
  • Fix a bug that could happen when using Python’s optimization (-O) flag that could leave an ordered bidict in an inconsistent state when dealing with duplicated, overwritten keys or values. If you do not use optimizations (specifically, skipping assert statements), this would not have affected you.
  • Fix a bug introduced by the optimizations in 0.13.0 that could cause a frozen bidict that compared equal to another mapping to have a different hash value from the other mapping, violating Python’s object model. This would only have affected you if you were inserting a frozen bidict and some other immutable mapping that it compared equal to into the same set or mapping.
  • Add equals_order_sensitive().
  • Reduce the memory usage of ordered bidicts.
  • Make copying of ordered bidicts faster.
  • Improvements to tests and CI, including:
    • Test on Windows
    • Test with PyPy3
    • Test with CPython 3.7-dev
    • Test with optimization flags
    • Require pylint to pass

Breaking API Changes

This release includes multiple API simplifications and improvements.

0.13.1 (2017-03-15)

  • Fix regression introduced by the new __subclasshook__ functionality in 0.13.0 so that issubclass(OldStyleClass, BidirectionalMapping) once again works with old-style classes, returning False rather than raising AttributeError (thanks, @knaperek).

0.13.0 (2017-01-19)

  • Support Python 3.6.

    (Earlier versions of bidict should work fine on 3.6, but it is officially supported starting in this version.)

  • BidirectionalMapping has been refactored into an abstract base class, following the way collections.abc.Mapping works. The concrete method implementations it used to provide have been moved into a new BidictBase subclass.

    BidirectionalMapping now also implements __subclasshook__, so any class that provides a conforming set of attributes (enumerated in _subclsattrs) will be considered a BidirectionalMapping subclass automatically.

  • OrderedBidirectionalMapping has been renamed to OrderedBidictBase, to better reflect its function. (It is not an ABC.)

  • A new FrozenBidictBase class has been factored out of frozenbidict and frozenorderedbidict. This implements common behavior such as caching the result of __hash__ after the first call.

  • The hash implementations of frozenbidict and frozenorderedbidict. have been reworked to improve performance and flexibility. frozenorderedbidict‘s hash implementation is now order-sensitive.

    See frozenbidict._compute_hash() and frozenorderedbidict._compute_hash for more documentation of the changes, including the new frozenbidict._USE_ITEMSVIEW_HASH and frozenorderedbidict._HASH_NITEMS_MAX attributes. If you have an interesting use case that requires overriding these, or suggestions for an alternative implementation, please share your feedback.

  • Add _fwd_class and _inv_class attributes representing the backing Mapping types used internally to store the forward and inverse dictionaries, respectively.

    This allows creating custom bidict types with extended functionality simply by overriding these attributes in a subclass.

    See the new Extending bidict documentation for examples.

  • Pass any parameters passed to bidict.popitem() through to _fwd.popitem for greater extensibility.

  • More concise repr strings for empty bidicts.

    e.g. bidict() rather than bidict({}) and orderedbidict() rather than orderedbidict([]).

  • Add bidict.compat.PYPY and remove unused bidict.compat.izip_longest.

0.12.0 (2016-07-03)

Breaking API Changes

  • Rename KeyExistsException to KeyDuplicationError and ValueExistsException to ValueDuplicationError.

  • When overwriting the key of an existing value in an orderedbidict, the position of the existing item is now preserved, overwriting the key of the existing item in place, rather than moving the item to the end. This now matches the behavior of overwriting the value of an existing key, which has always preserved the position of the existing item. (If inserting an item whose key duplicates that of one existing item and whose value duplicates that of another, the existing item whose value is duplicated is still dropped, and the existing item whose key is duplicated still gets its value overwritten in place, as before.)

    For example:

    >>> from bidict import orderedbidict  
    >>> o = orderedbidict([(0, 1), (2, 3)])  
    >>> o.forceput(4, 1)  
    

    previously would have resulted in:

    >>> o  
    orderedbidict([(2, 3), (4, 1)])
    

    but now results in:

    >>> o  
    orderedbidict([(4, 1), (2, 3)])
    

0.11.0 (2016-02-05)

0.10.0.post1 (2015-12-23)

  • Minor documentation fixes and improvements.

0.10.0 (2015-12-23)

  • Remove several features in favor of keeping the API simpler and the code more maintainable.
  • In the interest of protecting data safety more proactively, by default bidict now raises an error on attempting to insert a non-unique value, rather than allowing its associated key to be silently overwritten. See discussion in #21.
  • New forceupdate() method provides a bulk forceput() operation.
  • Fix bugs in pop() and setdefault() which could leave a bidict in an inconsistent state.

Breaking API Changes

  • Remove bidict.__invert__, and with it, support for the ~b syntax. Use b.inv instead. #19
  • Remove support for the slice syntax. Use b.inv[val] rather than b[:val]. #19
  • Remove bidict.invert. Use b.inv rather than inverting a bidict in place. #20
  • Raise ValueExistsException when attempting to insert a mapping with a non-unique key. #21
  • Rename collapsingbidict to loosebidict now that it suppresses ValueExistsException rather than the less general CollapseException. #21
  • CollapseException has been subsumed by ValueExistsException. #21
  • put() now raises KeyExistsException when attempting to insert an already-existing key, and ValueExistsException when attempting to insert an already-existing value.

0.9.0.post1 (2015-06-06)

  • Fix metadata missing in the 0.9.0rc0 release.

0.9.0rc0 (2015-05-30)

  • Add this changelog, Contributors’ Guide, Gitter chat room, and other community-oriented improvements.
  • Adopt Pytest (thanks Tom Viner and Adopt Pytest Month).
  • Add property-based tests via hypothesis.
  • Other code, tests, and docs improvements.

Breaking API Changes