bidict v0.14.0 Release Notes
Release Date: 2017-11-20 // over 6 years ago-
๐ Fix a bug where :class:
~bidict.bidict
\โs default on_dup_kv policy was set to :attr:~bidict.RAISE
, rather than matching whatever on_dup_val policy was in effect as was :ref:documented <basic-usage:Key and Value Duplication>
.๐ 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, skippingassert
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 :meth:
~bidict.OrderedBidictBase.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.
๐ Rename:
orderedbidict
โ :class:~bidict.OrderedBidict
frozenorderedbidict
โ :class:~bidict.FrozenOrderedBidict
so that these now match the case of :class:
collections.OrderedDict
.The names of the :class:
~bidict.bidict
, :func:~bidict.namedbidict
, and :class:~bidict.frozenbidict
classes have been retained as all-lowercase so that they continue to match the case of :class:dict
, :func:~collections.namedtuple
, and :class:frozenset
, respectively.The
ON_DUP_VAL
duplication policy value for on_dup_kv has been removed. UseNone
instead.๐ Merge :class:
~bidict.frozenbidict
andBidictBase
together and removeBidictBase
. :class:~bidict.frozenbidict
is now the concrete base class that all other bidict types derive from. See the updated :ref:other-bidict-types:Bidict Types Diagram
.๐ Merge :class:
~bidict.frozenbidict
andFrozenBidictBase
together and removeFrozenBidictBase
. See the updated :ref:other-bidict-types:Bidict Types Diagram
.๐ Merge
frozenorderedbidict
andOrderedBidictBase
together into a single :class:~bidict.FrozenOrderedBidict
class and removeOrderedBidictBase
. :class:~bidict.OrderedBidict
now extends :class:~bidict.FrozenOrderedBidict
to add mutable behavior. See the updated :ref:other-bidict-types:Bidict Types Diagram
.Make :meth:
~bidict.OrderedBidictBase.__eq__
always perform an order-insensitive equality test, even if the other mapping is ordered.
Previously, :meth:
~bidict.OrderedBidictBase.__eq__
was only order-sensitive for otherOrderedBidictBase
subclasses, and order-insensitive otherwise.Use the new :meth:
~bidict.OrderedBidictBase.equals_order_sensitive
method for order-sensitive equality comparison.orderedbidict._should_compare_order_sensitive()
has been removed.frozenorderedbidict._HASH_NITEMS_MAX
has been removed. Since its hash value must be computed from all contained items (so that hash results are consistent with equality comparisons against unordered mappings), the number of items that influence the hash value should not be limitable.๐
frozenbidict._USE_ITEMSVIEW_HASH
has been removed, andfrozenbidict.compute_hash()
now usescollections.ItemsView._hash()
to compute the hash always, not just when running on PyPy.
Override
frozenbidict.compute_hash()
to returnhash(frozenset(iteritems(self)))
if you prefer the old default behavior on CPython, which takes linear rather than constant space, but which uses thefrozenset_hash
routine (implemented insetobject.c
) rather than the pure PythonItemsView._hash()
routine.๐
loosebidict
andlooseorderedbidict
have been removed. A simple recipe to implement equivalents yourself is now given in :ref:extending:OverwritingBidict Recipe
.Rename
FrozenBidictBase._compute_hash()
โfrozenbidict.compute_hash()
.๐ Rename
DuplicationBehavior
โ :class:~bidict.DuplicationPolicy
.๐ Rename:
bidict.BidictBase._fwd_class
โ.fwd_cls
bidict.BidictBase._inv_class
โ.inv_cls
bidict.BidictBase._on_dup_key
โ :attr:~bidict.BidictBase.on_dup_key
bidict.BidictBase._on_dup_val
โ :attr:~bidict.BidictBase.on_dup_val
bidict.BidictBase._on_dup_kv
โ :attr:~bidict.BidictBase.on_dup_kv