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, 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 :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. Use None instead.

    • ๐Ÿ”€ Merge :class:~bidict.frozenbidict and BidictBase together and remove BidictBase. :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 and FrozenBidictBase together and remove FrozenBidictBase. See the updated :ref:other-bidict-types:Bidict Types Diagram.

    • ๐Ÿ”€ Merge frozenorderedbidict and OrderedBidictBase together into a single :class:~bidict.FrozenOrderedBidict class and remove OrderedBidictBase. :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 other OrderedBidictBase 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, and frozenbidict.compute_hash() now uses collections.ItemsView._hash() to compute the hash always, not just when running on PyPy.

    Override frozenbidict.compute_hash() to return hash(frozenset(iteritems(self))) if you prefer the old default behavior on CPython, which takes linear rather than constant space, but which uses the frozenset_hash routine (implemented in setobject.c) rather than the pure Python ItemsView._hash() routine.

    • ๐Ÿšš loosebidict and looseorderedbidict 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