Commit Graph

11 Commits

Author SHA1 Message Date
jab 0ec3b8b3e7 Various API changes and other improvements.
* 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`).

  A :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,
  a named (*key*, *val*, *kv*) tuple of :class:`~bidict.OnDupAction`\s
  that should be taken upon encountering
  the 3 kinds of duplication that can occur.

* 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.

  They 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=DROP_NEW))``.
  Or better yet, pass one of the
  ``ON_DUP_*`` convenience instances
  instead if possible.

  See the updated :ref:`basic-usage:Values Must Be Unique` docs for more info.

* Deprecate the
  ``on_dup_key``, ``on_dup_val``, and ``on_dup_kv``
  bidict class attributes.
  A :class:`UserWarning` will now be emitted if these are used.

  They 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.

* Move
  :meth:`bidict.BidictBase.values` to
  :meth:`bidict.BidirectionalMapping.values`,
  since the implementation is generic.

* No longer use ``__all__`` in ``bidict/__init__.py``.

* Cap max_size rather than disabling health checks and deadline as a
  less heavyhanded way to improve hypothesis test reliability on Travis.
2020-01-07 17:20:25 -05:00
jab d2b5adcce3 Happy 2020 🎉 2019-12-31 18:14:38 -05:00
jab ba1cba8523 happy 2019 2019-01-01 13:51:46 -05:00
jab d13fd9bb8a resurrect delegating mixins instead of __delegate__ + other refinements
e.g. s/__repr_delegate__/_repr_delegate

Also
- update
- update from pytest 3 to 4
- add CII best practices badge
- prepare for 0.17.5 release
2018-11-19 09:37:38 -05:00
jab 3a8339d29c OrderedBidict optimizations and code improvements.
Use bidicts for the backing ``_fwdm`` and ``_invm`` mappings,
obviating the need to store key and value data in linked list nodes.

Also drop the unnecessary ^ from the namedtuple identifier regexes.
2018-11-06 16:10:03 -05:00
jab 6faf1ef03f Fix updating orderedbidict.inv 2018-04-28 09:50:29 +08:00
jab bfb6ed2a3b finish refactoring, misc. bugfixes, improve docs + tests 2018-02-28 00:09:57 +11:00
jab 459f9365cf improve test coverage 2018-02-19 18:53:03 +11:00
jab d0c6fdae3b happy 2018 2017-12-31 22:51:19 -05:00
jab 64ed7278d8
more API and code improvements
including:
- simplify type hierarchy, merging the frozen types into the base types
- upgrade to latest hypothesis (3.38.0)
- use Reversible for order-sensitive FrozenOrderedBidict.__eq__
- fix bug where bidict._on_dup_kv was not set to ON_DUP_VAL as documented
- drop leading underscore from attrs that should be public
- improve setup.py/metadata
- rename DuplicationBehavior -> DuplicationPolicy
- drop ON_DUP_VAL duplication policy in preference to just using None
- reduce ordered bidict memory usage and speed up copy
2017-11-19 22:24:08 -05:00
jab 22f4e78d09
numerous fixes and improvements (#43)
- .travis.yml and setup.py tweaks
- add regression tests for -O bug and document fix
- Make OrderedBidict equality comparison order-sensitive in more cases.
- Add bidict.BidictBase.ordered class attribute.
- Replacing OrderedBidictBase._should_compare_order_sensitive()
  with OrderedBidictBase.should_compare_order_sensitive_to().
- Revert the optimizations in v0.13.0 to make FrozenOrderedBidict instances
  that have the same items in different order have different hash values.
- Remove FrozenBidictBase.
- Remove frozenbidict._USE_ITEMSVIEW_HASH and
  frozenorderedbidict._HASH_NITEMS_MAX
2017-11-17 22:35:40 -05:00