bidict v0.19.0 Release Notes

Release Date: 2020-01-09 // over 4 years ago
    • โฌ‡๏ธ Drop support for Python 2 :ref:as promised in v0.18.2 <changelog:0.18.2 (2019-09-08)>.

    The :mod:bidict.compat module has been pruned accordingly.

    This makes bidict more efficient on Python 3 and enables further improvement to bidict in the future.

    • ๐Ÿ—„ Deprecate bidict.OVERWRITE and bidict.IGNORE. A :class:UserWarning will now be emitted if these are used.

    :attr:bidict.DROP_OLD and :attr:bidict.DROP_NEW should be used instead.

    • ๐Ÿ“‡ Rename DuplicationPolicy to :class:~bidict.OnDupAction (and implement it via an :class:~enum.Enum).

    An :class:~bidict.OnDupAction may be one of :attr:~bidict.RAISE, :attr:~bidict.DROP_OLD, or :attr:~bidict.DROP_NEW.

    • ๐Ÿ”ฆ Expose the new :class:~bidict.OnDup class to contain the three :class:~bidict.OnDupAction\s that should be taken upon encountering the three kinds of duplication that can occur (key, val, kv).

    • Provide the :attr:~bidict.ON_DUP_DEFAULT, :attr:~bidict.ON_DUP_RAISE, and :attr:~bidict.ON_DUP_DROP_OLD :class:~bidict.OnDup convenience instances.

    • ๐Ÿ—„ Deprecate the on_dup_key, on_dup_val, and on_dup_kv arguments of :meth:~bidict.bidict.put and :meth:~bidict.bidict.putall. A :class:UserWarning will now be emitted if these are used.

    These have been subsumed by the new on_dup argument, which takes an :class:~bidict.OnDup instance.

    Use it like this: bi.put(1, 2, OnDup(key=RAISE, val=...)). Or pass one of the instances already provided, such as :attr:~bidict.ON_DUP_DROP_OLD. Or just don't pass an on_dup argument to use the default value of :attr:~bidict.ON_DUP_RAISE.

    The :ref:basic-usage:Values Must Be Unique docs have been updated accordingly.

    • ๐Ÿ—„ Deprecate the on_dup_key, on_dup_val, and on_dup_kv :class:~bidict.bidict class attributes. A :class:UserWarning will now be emitted if these are used.

    These have been subsumed by the new :attr:~bidict.bidict.on_dup class attribute, which takes an :class:~bidict.OnDup instance.

    See the updated :doc:extending docs for example usage.

    • ๐Ÿ‘Œ Improve the more efficient implementations of :meth:~bidict.BidirectionalMapping.keys, :meth:~bidict.BidirectionalMapping.values, and :meth:~bidict.BidirectionalMapping.items, and now also provide a more efficient implementation of :meth:~bidict.BidirectionalMapping.__iter__ by delegating to backing :class:dict\s in the bidict types for which this is possible.

    • ๐Ÿšš Move :meth:bidict.BidictBase.values to :meth:bidict.BidirectionalMapping.values, since the implementation is generic.

    • No longer use __all__ in :mod:bidict's __init__.py.