| 1 |
.. Forward declarations for all the custom interpreted text roles that |
| 2 |
Sphinx defines and that are used below. This helps Sphinx-unaware tools |
| 3 |
(e.g. rst2html, PyPI's and GitHub's renderers, etc.). |
| 4 |
.. role:: doc |
| 5 |
.. role:: ref |
| 6 |
|
| 7 |
|
| 8 |
Changelog |
| 9 |
========= |
| 10 |
|
| 11 |
:sup:`If you or your organization depends on bidict, |
| 12 |
please consider sponsoring bidict on GitHub.` |
| 13 |
|
| 14 |
|
| 15 |
.. tip:: |
| 16 |
Watch `bidict releases on GitHub <https://github.com/jab/bidict/releases>`__ |
| 17 |
to be notified when new versions of bidict are published. |
| 18 |
Click the "Watch" dropdown, choose "Custom", and then choose "Releases". |
| 19 |
|
| 20 |
|
| 21 |
0.24.1 (2026-08-25) |
| 22 |
------------------- |
| 23 |
|
| 24 |
- Fix the ``RECORD`` file in the published 0.24.0 wheel |
| 25 |
by upgrading to a fixed version of ``uv_build``. |
| 26 |
:issue:`406` |
| 27 |
|
| 28 |
- Fix a test failure on Python 3.15 |
| 29 |
caused by changes to :class:`~collections.UserDict`. |
| 30 |
:issue:`407` |
| 31 |
|
| 32 |
|
| 33 |
0.24.0 (2026-08-24) |
| 34 |
------------------- |
| 35 |
|
| 36 |
- Remove ``bidict.metadata`` and associated metadata from the |
| 37 |
:mod:`bidict` module (e.g. ``bidict.__version__``). |
| 38 |
Use e.g. :func:`importlib.metadata.metadata("bidict")["Version"] |
| 39 |
<importlib.metadata.metadata>` instead. |
| 40 |
|
| 41 |
- Fix a bug where pickling or :func:`~copy.deepcopy`\ing an instance of a |
| 42 |
dynamically-generated inverse class |
| 43 |
(see :ref:`extending:Dynamic Inverse Class Generation`) |
| 44 |
could change the order of its items. |
| 45 |
:issue:`398` |
| 46 |
|
| 47 |
Pickles written by bidict 0.23.1 and earlier can no longer be read. |
| 48 |
They call the private ``BidictBase._from_other()`` |
| 49 |
with an argument it no longer accepts, |
| 50 |
which was retained for no other purpose. |
| 51 |
Pickle compatibility across versions |
| 52 |
`has never been guaranteed |
| 53 |
<https://docs.python.org/3/library/pickle.html#comparison-with-json>`__, |
| 54 |
and dropping it here keeps |
| 55 |
:meth:`~bidict.BidictBase.__reduce__` free of special cases. |
| 56 |
|
| 57 |
- Fix a bug where a non-ordered bidict's |
| 58 |
:meth:`~bidict.BidictBase.values` view |
| 59 |
could yield its values in a different order than |
| 60 |
:meth:`~bidict.BidictBase.keys` yields the corresponding keys, |
| 61 |
so that e.g. ``zip(b.keys(), b.values())`` |
| 62 |
silently paired up the wrong keys and values. |
| 63 |
|
| 64 |
- Fix a bug where :meth:`~bidict.MutableBidict.putall` |
| 65 |
and :meth:`~bidict.MutableBidict.update` |
| 66 |
could leave earlier items inserted when a later item in a bulk update |
| 67 |
raised a non-duplication exception, |
| 68 |
rather than failing clean. |
| 69 |
:issue:`389` |
| 70 |
|
| 71 |
- Fix a bug where a bulk update did not fail clean at all |
| 72 |
when the :class:`~bidict.OnDup` in effect contained no |
| 73 |
:attr:`~bidict.RAISE` action – |
| 74 |
as with :meth:`~bidict.MutableBidict.forceupdate`, |
| 75 |
:meth:`~bidict.MutableBidict.putall` passed :attr:`~bidict.ON_DUP_DROP_OLD`, |
| 76 |
or :meth:`~bidict.MutableBidict.update` on a subclass |
| 77 |
that overrides :attr:`~bidict.BidictBase.on_dup` |
| 78 |
(e.g. the ``YoloBidict`` recipe in :doc:`extending`). |
| 79 |
Rollback was previously enabled only when a duplication error was possible, |
| 80 |
but a bulk update can also fail while unpacking an item, |
| 81 |
hashing a key or value, or writing to a backing mapping. |
| 82 |
Rollback is now always enabled for these methods. |
| 83 |
:issue:`392` |
| 84 |
|
| 85 |
- Fix a bug where a write or removal that a custom backing mapping refused |
| 86 |
could leave a custom bidict's two backing mappings out of sync, |
| 87 |
breaking the bidirectional invariant, |
| 88 |
rather than failing clean. |
| 89 |
:issue:`401` |
| 90 |
:issue:`403` |
| 91 |
|
| 92 |
- Fix a bug where mutating an :class:`~bidict.OrderedBidict` |
| 93 |
while iterating over it produced incorrect behavior |
| 94 |
rather than raising an error. |
| 95 |
:issue:`393` |
| 96 |
|
| 97 |
- A bidict and its inverse now always refer to the same object |
| 98 |
for each contained key and value, |
| 99 |
rather than possibly to equivalent but distinct ones, |
| 100 |
so that e.g. ``b.inverse[b[key]] is key`` always holds. |
| 101 |
Writing an item whose key or value is equal to a contained one |
| 102 |
now keeps the object already contained, |
| 103 |
as :class:`dict` does when a key is overwritten, |
| 104 |
instead of keeping one object in each direction. |
| 105 |
*See also* :ref:`addendum:Equivalent but distinct \:class\:\`~collections.abc.Hashable\`\\s` |
| 106 |
:issue:`396` |
| 107 |
|
| 108 |
- Fix a bug where setting an already-contained (key, value) pair |
| 109 |
spuriously raised :class:`~bidict.KeyAndValueDuplicationError` |
| 110 |
or ``AssertionError`` (rather than being a no-op, as documented) |
| 111 |
when the key or value has non-reflexive equality (e.g. *nan*) |
| 112 |
or asymmetric equality. |
| 113 |
:issue:`377` |
| 114 |
|
| 115 |
- Fix a bug where set operations between an :class:`~bidict.OrderedBidict`'s |
| 116 |
keys view and its items view (or vice versa) raised :class:`TypeError` |
| 117 |
(or, for ``==``, returned the wrong result) |
| 118 |
rather than behaving like the equivalent plain :class:`dict` views. |
| 119 |
:issue:`376` |
| 120 |
|
| 121 |
- Single-item writes such as |
| 122 |
:meth:`~bidict.MutableBidict.__setitem__`, |
| 123 |
:meth:`~bidict.MutableBidict.put`, and |
| 124 |
:meth:`~bidict.MutableBidict.forceput` |
| 125 |
are now ~6x faster: |
| 126 |
most of what they cost was never the write itself, |
| 127 |
but typing machinery being re-evaluated on every call. |
| 128 |
Iterating an :class:`~bidict.OrderedBidict` is also ~1.2x faster. |
| 129 |
Everything else is within a couple of percent of 0.23.1. |
| 130 |
|
| 131 |
- A bidict backed by a :class:`dict` *subclass* |
| 132 |
now gets that mapping's own views from |
| 133 |
:meth:`~bidict.BidictBase.keys` and :meth:`~bidict.BidictBase.items`, |
| 134 |
as a bidict backed by an exact :class:`dict` already did. |
| 135 |
Previously only an exact :class:`dict` qualified, |
| 136 |
so such a bidict got generic views instead, |
| 137 |
which were not :class:`~collections.abc.Reversible` |
| 138 |
(even when the bidict itself was), |
| 139 |
had no ``.mapping`` attribute, |
| 140 |
and performed their set operations in Python rather than in C. |
| 141 |
This affects every backing mapping used in the recipes in :doc:`extending`, |
| 142 |
since :class:`collections.OrderedDict`, |
| 143 |
:class:`collections.defaultdict`, |
| 144 |
and ``sortedcontainers.SortedDict`` |
| 145 |
are all :class:`dict` subclasses. |
| 146 |
|
| 147 |
- Fix a bug where a subclass of a bidict class |
| 148 |
whose backing mappings are not :class:`~collections.abc.Reversible` |
| 149 |
could not itself be reversible, |
| 150 |
even when it specified backing mappings that are. |
| 151 |
|
| 152 |
- Fix a bug where an :class:`~bidict.OrderedBidictBase` that is not an |
| 153 |
:class:`~bidict.OrderedBidict` |
| 154 |
could yield its items in the wrong order from |
| 155 |
:meth:`~bidict.OrderedBidictBase.keys`, |
| 156 |
:meth:`~bidict.OrderedBidictBase.items`, |
| 157 |
:meth:`~bidict.BidictBase.values`, |
| 158 |
:func:`repr`, and |
| 159 |
:meth:`~bidict.BidictBase.equals_order_sensitive`. |
| 160 |
|
| 161 |
|
| 162 |
0.23.1 (2024-02-18) |
| 163 |
------------------- |
| 164 |
|
| 165 |
Fix a regression in 0.23.0 that could defeat type inference |
| 166 |
of a bidict's key type and value type when running in Python 3.8 or 3.9. |
| 167 |
:issue:`310` |
| 168 |
|
| 169 |
|
| 170 |
0.23.0 (2024-02-14) |
| 171 |
------------------- |
| 172 |
|
| 173 |
Primarily, this release simplifies bidict by removing minor features |
| 174 |
that are no longer necessary or that have little to no apparent usage, |
| 175 |
and it also includes some performance optimizations. |
| 176 |
|
| 177 |
Specifically, initializing or updating a bidict |
| 178 |
is now up to 70% faster in microbenchmarks. |
| 179 |
|
| 180 |
The changes in this release will also make it easier |
| 181 |
to maintain and improve bidict in the future, |
| 182 |
including further potential performance optimizations. |
| 183 |
|
| 184 |
It also contains several other improvements. |
| 185 |
|
| 186 |
- Drop support for Python 3.7, |
| 187 |
which reached end of life on 2023-06-27, |
| 188 |
and take advantage of features available in Python 3.8+. |
| 189 |
|
| 190 |
- Remove ``FrozenOrderedBidict`` now that Python 3.7 is no longer supported. |
| 191 |
:class:`~bidict.frozenbidict` now provides everything |
| 192 |
that ``FrozenOrderedBidict`` provided |
| 193 |
(including :class:`reversibility <collections.abc.Reversible>`) |
| 194 |
on all supported Python versions, |
| 195 |
but with less space overhead. |
| 196 |
|
| 197 |
- Remove ``namedbidict`` due to low usage. |
| 198 |
|
| 199 |
- Remove the ``kv`` field of :class:`~bidict.OnDup` |
| 200 |
which specified the :class:`~bidict.OnDupAction` to take |
| 201 |
in the case of :ref:`basic-usage:key and value duplication`. |
| 202 |
The :attr:`~bidict.OnDup.val` field now specifies the action to take |
| 203 |
in the case of |
| 204 |
:ref:`basic-usage:key and value duplication` |
| 205 |
as well as |
| 206 |
:ref:`just value duplication <basic-usage:values must be unique>`. |
| 207 |
|
| 208 |
- Improve type hints for the |
| 209 |
:attr:`~bidict.BidictBase.inv` shortcut alias |
| 210 |
for :attr:`~bidict.BidictBase.inverse`. |
| 211 |
|
| 212 |
- Fix a bug where calls like |
| 213 |
``bidict(None)``, ``bi.update(False)``, etc. |
| 214 |
would fail to raise a :class:`TypeError`. |
| 215 |
|
| 216 |
- All :meth:`~bidict.BidictBase.__init__`, |
| 217 |
:meth:`~bidict.MutableBidict.update`, |
| 218 |
and related methods |
| 219 |
now handle `SupportsKeysAndGetItem |
| 220 |
<https://github.com/python/typeshed/blob/3eb9ff/stdlib/_typeshed/__init__.pyi#L128-L131>`__ |
| 221 |
objects that are not :class:`~collections.abc.Mapping`\s |
| 222 |
the same way that `MutableMapping.update() |
| 223 |
<https://github.com/python/cpython/blob/v3.11.5/Lib/_collections_abc.py#L943>`__ does, |
| 224 |
before falling back to handling the provided object as an iterable of pairs. |
| 225 |
|
| 226 |
- The :func:`repr` of ordered bidicts now matches that of regular bidicts, |
| 227 |
e.g. ``OrderedBidict({1: 1})`` rather than ``OrderedBidict([(1, 1)])``. |
| 228 |
|
| 229 |
(Accordingly, the ``bidict.__repr_delegate__`` field has been removed |
| 230 |
now that it's no longer needed.) |
| 231 |
|
| 232 |
This tracks with the change to :class:`collections.OrderedDict`\'s :func:`repr` |
| 233 |
`in Python 3.12 <https://github.com/python/cpython/pull/101661>`__. |
| 234 |
|
| 235 |
- Test with Python 3.12 in CI. |
| 236 |
|
| 237 |
Note: Older versions of bidict also support Python 3.12, |
| 238 |
even though they don't explicitly declare support for it. |
| 239 |
|
| 240 |
- Drop use of `Trove classifiers <https://github.com/pypa/trove-classifiers>`__ |
| 241 |
that declare support for specific Python versions in package metadata. |
| 242 |
|
| 243 |
|
| 244 |
0.22.1 (2022-12-31) |
| 245 |
------------------- |
| 246 |
|
| 247 |
- Only include the source code in the source distribution. |
| 248 |
This reduces the size of the source distribution |
| 249 |
from ~200kB to ~30kB. |
| 250 |
|
| 251 |
- Fix the return type hint of :func:`bidict.inverted` |
| 252 |
to return an :class:`~collections.abc.Iterator`, |
| 253 |
rather than an :class:`~collections.abc.Iterable`. |
| 254 |
|
| 255 |
|
| 256 |
0.22.0 (2022-03-23) |
| 257 |
------------------- |
| 258 |
|
| 259 |
- Drop support for Python 3.6, which reached end of life on 2021-12-23 |
| 260 |
and is no longer supported by pip as of pip version 22. |
| 261 |
Take advantage of this to reduce bidict's maintenance costs. |
| 262 |
|
| 263 |
- Use mypy-appeasing explicit re-exports in ``__init__.py`` |
| 264 |
(e.g. ``import x as x``) |
| 265 |
so that mypy no longer gives you an implicit re-export error |
| 266 |
if you run it with ``--no-implicit-reexport`` (or ``--strict``) |
| 267 |
against code that imports from :mod:`bidict`. |
| 268 |
|
| 269 |
- Update the implementations and type annotations of |
| 270 |
:meth:`bidict.BidictBase.keys` and |
| 271 |
:meth:`bidict.BidictBase.values` to make use of the new |
| 272 |
:class:`~bidict.BidictKeysView` type, |
| 273 |
which works a bit better with type checkers. |
| 274 |
|
| 275 |
- Inverse bidict instances are now computed lazily the first time |
| 276 |
the :attr:`~bidict.BidictBase.inverse` attribute is accessed |
| 277 |
rather than being computed eagerly during initialization. |
| 278 |
(A bidict's backing, inverse, one-way mapping |
| 279 |
is still kept in sync eagerly as any mutations are made, |
| 280 |
to preserve key- and value-uniqueness.) |
| 281 |
|
| 282 |
- Optimize initializing a bidict with another bidict. |
| 283 |
In a microbenchmark on Python 3.10, |
| 284 |
this now performs over **2x faster**. |
| 285 |
|
| 286 |
- Optimize updating an empty bidict with another bidict. |
| 287 |
In a microbenchmark on Python 3.10, |
| 288 |
this now performs **60-75% faster**. |
| 289 |
|
| 290 |
- Optimize :meth:`~bidict.BidictBase.copy`. |
| 291 |
In a microbenchmark on Python 3.10, |
| 292 |
this now performs **10-20x faster**. |
| 293 |
|
| 294 |
- Optimize rolling back |
| 295 |
:ref:`failed updates to a bidict <basic-usage:Updates Fail Clean>` |
| 296 |
in the case that the number of items passed to the update call |
| 297 |
can be determined to be larger than the bidict being updated. |
| 298 |
Previously this rollback was O(n) in the number of items passed. |
| 299 |
Now it is O(1), i.e. **unboundedly faster**. |
| 300 |
|
| 301 |
- Optimize :meth:`bidict.BidictBase.__contains__` |
| 302 |
(the method called when you run ``key in mybidict``). |
| 303 |
In a microbenchmark on Python 3.10, |
| 304 |
this now performs over **3-10x faster** in the False case, |
| 305 |
and at least **50% faster** in the True case. |
| 306 |
|
| 307 |
- Optimize :meth:`bidict.BidictBase.__eq__` |
| 308 |
(the method called when you run ``mybidict == other``). |
| 309 |
In a microbenchmark on Python 3.10, |
| 310 |
this now performs **15-25x faster** for ordered bidicts, |
| 311 |
and **7-12x faster** for unordered bidicts. |
| 312 |
|
| 313 |
- Optimize :meth:`~bidict.BidictBase.equals_order_sensitive`. |
| 314 |
In a microbenchmark on Python 3.10, |
| 315 |
this now performs **2x faster** for ordered bidicts |
| 316 |
and **60-90% faster** for unordered bidicts. |
| 317 |
|
| 318 |
- Optimize the |
| 319 |
:class:`~collections.abc.MappingView` objects returned by |
| 320 |
:meth:`bidict.OrderedBidict.keys <bidict.OrderedBidictBase.keys>`, |
| 321 |
:meth:`bidict.OrderedBidict.values <bidict.BidictBase.values>`, and |
| 322 |
:meth:`bidict.OrderedBidict.items <bidict.OrderedBidictBase.items>` |
| 323 |
to delegate to backing ``dict_keys`` and ``dict_items`` |
| 324 |
objects if available, which are much faster in CPython. |
| 325 |
For example, in a microbenchmark on Python 3.10, |
| 326 |
``orderedbi.items() == d.items()`` |
| 327 |
now performs **30-50x faster**. |
| 328 |
|
| 329 |
- Fix a bug where |
| 330 |
:meth:`bidict.BidictBase.__eq__` was always returning False |
| 331 |
rather than :obj:`NotImplemented` |
| 332 |
in the case that the argument was not a |
| 333 |
:class:`~collections.abc.Mapping`, |
| 334 |
defeating the argument's own ``__eq__()`` if implemented. |
| 335 |
As a notable example, bidicts now correctly compare equal to |
| 336 |
:obj:`unittest.mock.ANY`. |
| 337 |
|
| 338 |
- :class:`bidict.BidictBase` now adds a ``__reversed__`` implementation |
| 339 |
to subclasses that don't have an overridden implementation |
| 340 |
depending on whether both their backing mappings are |
| 341 |
:class:`~collections.abc.Reversible`. |
| 342 |
Previously, a ``__reversed__`` implementation was only added to |
| 343 |
:class:`~bidict.BidictBase` when ``BidictBase._fwdm_cls`` was |
| 344 |
:class:`~collections.abc.Reversible`. |
| 345 |
So if a :class:`~bidict.BidictBase` subclass set its ``_fwdm_cls`` |
| 346 |
to a non-reversible mutable mapping, |
| 347 |
it would also have to manually set its ``__reversed__`` attribute to None |
| 348 |
to override the implementation inherited from :class:`~bidict.BidictBase`. |
| 349 |
This is no longer necessary thanks to bidict's new |
| 350 |
:meth:`object.__init_subclass__` logic. |
| 351 |
|
| 352 |
- The |
| 353 |
:class:`~collections.abc.MappingView` objects |
| 354 |
returned by |
| 355 |
:meth:`bidict.OrderedBidict.keys <bidict.OrderedBidictBase.keys>`, |
| 356 |
:meth:`bidict.OrderedBidict.values <bidict.BidictBase.values>`, and |
| 357 |
:meth:`bidict.OrderedBidict.items <bidict.OrderedBidictBase.items>` |
| 358 |
are now |
| 359 |
:class:`~collections.abc.Reversible`. |
| 360 |
(This was already the case for unordered bidicts |
| 361 |
when running on Python 3.8+.) |
| 362 |
|
| 363 |
- Add support for Python 3.9-style dict merge operators |
| 364 |
(`PEP 584 <https://www.python.org/dev/peps/pep-0584/>`__). |
| 365 |
|
| 366 |
See `the tests <https://github.com/jab/bidict/blob/main/tests/>`__ |
| 367 |
for examples. |
| 368 |
|
| 369 |
- Update docstrings for |
| 370 |
:meth:`bidict.BidictBase.keys`, |
| 371 |
:meth:`bidict.BidictBase.values`, and |
| 372 |
:meth:`bidict.BidictBase.items` |
| 373 |
to include more details. |
| 374 |
|
| 375 |
- ``namedbidict`` now |
| 376 |
exposes the passed-in *keyname* and *valname* |
| 377 |
in the corresponding properties on the generated class. |
| 378 |
|
| 379 |
- ``namedbidict`` now requires *base_type* |
| 380 |
to be a subclass of :class:`~bidict.BidictBase`, |
| 381 |
but no longer requires *base_type* to provide |
| 382 |
an ``_isinv`` attribute, |
| 383 |
which :class:`~bidict.BidictBase` subclasses no longer provide. |
| 384 |
|
| 385 |
- When attempting to pickle a bidict's inverse whose class was |
| 386 |
:ref:`dynamically generated |
| 387 |
<extending:Dynamic Inverse Class Generation>`, |
| 388 |
and no reference to the dynamically-generated class has been stored |
| 389 |
anywhere in :data:`sys.modules` where :mod:`pickle` can find it, |
| 390 |
the pickle call is now more likely to succeed |
| 391 |
rather than failing with a :class:`~pickle.PicklingError`. |
| 392 |
|
| 393 |
- Remove the use of slots from (non-ABC) bidict types. |
| 394 |
|
| 395 |
This better matches the mapping implementations in Python's standard library, |
| 396 |
and significantly reduces code complexity and maintenance burden. |
| 397 |
The memory savings conferred by using slots are not noticeable |
| 398 |
unless you're creating millions of bidict instances anyway, |
| 399 |
which is an extremely unusual usage pattern. |
| 400 |
|
| 401 |
Of course, bidicts can still contain millions (or more) items |
| 402 |
(which is not an unusual usage pattern) |
| 403 |
without using any more memory than before these changes. |
| 404 |
Notably, slots are still used in the internal linked list nodes of ordered bidicts |
| 405 |
to save memory, since as many node instances are created as there are items inserted. |
| 406 |
|
| 407 |
|
| 408 |
0.21.4 (2021-10-23) |
| 409 |
------------------- |
| 410 |
|
| 411 |
Explicitly declare support for Python 3.10 |
| 412 |
as well as some minor internal improvements. |
| 413 |
|
| 414 |
|
| 415 |
0.21.3 (2021-09-05) |
| 416 |
------------------- |
| 417 |
|
| 418 |
- All bidicts now provide the :meth:`~bidict.BidictBase.equals_order_sensitive` method, |
| 419 |
not just :class:`~bidict.OrderedBidict`\s. |
| 420 |
|
| 421 |
Since support for Python < 3.6 was dropped in v0.21.0, |
| 422 |
:class:`dict`\s provide a deterministic ordering |
| 423 |
on all supported Python versions, |
| 424 |
and as a result, all bidicts do too. |
| 425 |
So now even non-:class:`Ordered <bidict.OrderedBidict>` bidicts |
| 426 |
might as well provide :meth:`~bidict.BidictBase.equals_order_sensitive`. |
| 427 |
|
| 428 |
See the updated |
| 429 |
:ref:`other-bidict-types:What about order-preserving dicts?` docs for more info. |
| 430 |
|
| 431 |
- Take better advantage of the fact that dicts became |
| 432 |
:class:`reversible <collections.abc.Reversible>` in Python 3.8. |
| 433 |
|
| 434 |
Specifically, now even non-:class:`Ordered <bidict.OrderedBidict>` bidicts |
| 435 |
provide a :meth:`~bidict.BidictBase.__reversed__` implementation on Python 3.8+ |
| 436 |
that calls :func:`reversed` on the backing ``_fwdm`` mapping. |
| 437 |
|
| 438 |
As a result, if you are using Python 3.8+, |
| 439 |
:class:`~bidict.frozenbidict` now gives you everything that |
| 440 |
``FrozenOrderedBidict`` gives you, |
| 441 |
but with less space overhead. |
| 442 |
|
| 443 |
- Drop `setuptools_scm <https://github.com/pypa/setuptools_scm>`__ |
| 444 |
as a ``setup_requires`` dependency. |
| 445 |
|
| 446 |
- Remove the ``bidict.__version_info__`` attribute. |
| 447 |
|
| 448 |
|
| 449 |
0.21.2 (2020-09-07) |
| 450 |
------------------- |
| 451 |
|
| 452 |
- Include `py.typed <https://www.python.org/dev/peps/pep-0561/#packaging-type-information>`__ |
| 453 |
file to mark :mod:`bidict` as type hinted. |
| 454 |
|
| 455 |
|
| 456 |
0.21.1 (2020-09-07) |
| 457 |
------------------- |
| 458 |
|
| 459 |
This release was yanked and replaced with the 0.21.2 release, |
| 460 |
which actually provides the intended changes. |
| 461 |
|
| 462 |
|
| 463 |
0.21.0 (2020-08-22) |
| 464 |
------------------- |
| 465 |
|
| 466 |
- :mod:`bidict` now provides |
| 467 |
`type hints <https://www.python.org/dev/peps/pep-0484/>`__! ⌨️ ✅ |
| 468 |
|
| 469 |
Adding type hints to :mod:`bidict` poses particularly interesting challenges |
| 470 |
due to the combination of generic types, |
| 471 |
dynamically-generated types |
| 472 |
(such as :ref:`inverse bidict classes <extending:Dynamic Inverse Class Generation>` |
| 473 |
and ``namedbidict``\s), |
| 474 |
and complicating optimizations |
| 475 |
such as the use of slots and weakrefs. |
| 476 |
|
| 477 |
It didn't take long to hit bugs and missing features |
| 478 |
in the state of the art for type hinting in Python today, |
| 479 |
e.g. missing higher-kinded types support |
| 480 |
(`python/typing#548 <https://github.com/python/typing/issues/548#issuecomment-621195693>`__), |
| 481 |
too-narrow type hints for :class:`collections.abc.Mapping` |
| 482 |
(`python/typeshed#4435 <https://github.com/python/typeshed/issues/4435>`__), |
| 483 |
a :class:`typing.Generic` bug in Python 3.6 |
| 484 |
(`BPO-41451 <https://bugs.python.org/issue41451>`__), etc. |
| 485 |
|
| 486 |
That said, this release should provide a solid foundation |
| 487 |
for code using :mod:`bidict` that enables static type checking. |
| 488 |
|
| 489 |
As always, if you spot any opportunities to improve :mod:`bidict` |
| 490 |
(including its new type hints), |
| 491 |
please don't hesitate to submit a PR! |
| 492 |
|
| 493 |
- Add :class:`bidict.MutableBidirectionalMapping` ABC. |
| 494 |
|
| 495 |
The :ref:`other-bidict-types:Bidict Types Diagram` has been updated accordingly. |
| 496 |
|
| 497 |
- Drop support for Python 3.5, |
| 498 |
which reaches end of life on 2020-09-13, |
| 499 |
represents a tiny percentage of bidict downloads on |
| 500 |
`PyPI Stats <https://pypistats.org/packages/bidict>`__, |
| 501 |
and lacks support for |
| 502 |
`variable type hint syntax <https://www.python.org/dev/peps/pep-0526/>`__, |
| 503 |
`ordered dicts <https://stackoverflow.com/a/39980744>`__, |
| 504 |
and :attr:`object.__init_subclass__`. |
| 505 |
|
| 506 |
- Remove the no-longer-needed ``bidict.compat`` module. |
| 507 |
|
| 508 |
- Move :ref:`inverse bidict class access <extending:Dynamic Inverse Class Generation>` |
| 509 |
from a property to an attribute set in |
| 510 |
:attr:`~bidict.BidictBase.__init_subclass__`, |
| 511 |
to save function call overhead on repeated access. |
| 512 |
|
| 513 |
- :meth:`bidict.OrderedBidictBase.__iter__` no longer accepts |
| 514 |
a ``reverse`` keyword argument so that it matches the signature of |
| 515 |
:meth:`container.__iter__`. |
| 516 |
|
| 517 |
- Set the ``__module__`` attribute of various :mod:`bidict` types |
| 518 |
(using :func:`sys._getframe` when necessary) |
| 519 |
so that private, internal modules are not exposed |
| 520 |
e.g. in classes' repr strings. |
| 521 |
|
| 522 |
- ``namedbidict`` now immediately raises :class:`TypeError` |
| 523 |
if the provided ``base_type`` does not provide |
| 524 |
``_isinv`` or :meth:`~object.__getstate__`, |
| 525 |
rather than succeeding with a class whose instances may raise |
| 526 |
:class:`AttributeError` when these attributes are accessed. |
| 527 |
|
| 528 |
|
| 529 |
0.20.0 (2020-07-23) |
| 530 |
------------------- |
| 531 |
|
| 532 |
The following breaking changes are expected to affect few if any users. |
| 533 |
|
| 534 |
Remove APIs deprecated in the previous release: |
| 535 |
|
| 536 |
- ``bidict.OVERWRITE`` and ``bidict.IGNORE``. |
| 537 |
|
| 538 |
- The ``on_dup_key``, ``on_dup_val``, and ``on_dup_kv`` arguments of |
| 539 |
:meth:`~bidict.MutableBidict.put` and :meth:`~bidict.MutableBidict.putall`. |
| 540 |
|
| 541 |
- The ``on_dup_key``, ``on_dup_val``, and ``on_dup_kv`` |
| 542 |
:class:`~bidict.bidict` class attributes. |
| 543 |
|
| 544 |
- Remove ``bidict.BidirectionalMapping.__subclasshook__`` |
| 545 |
due to lack of use and maintenance cost. |
| 546 |
|
| 547 |
Fixes a bug introduced in 0.15.0 |
| 548 |
that caused any class with an ``inverse`` attribute |
| 549 |
to be incorrectly considered a subclass of :class:`collections.abc.Mapping`. |
| 550 |
:issue:`111` |
| 551 |
|
| 552 |
|
| 553 |
0.19.0 (2020-01-09) |
| 554 |
------------------- |
| 555 |
|
| 556 |
- Drop support for Python 2 |
| 557 |
:ref:`as promised in v0.18.2 <changelog:0.18.2 (2019-09-08)>`. |
| 558 |
|
| 559 |
The ``bidict.compat`` module has been pruned accordingly. |
| 560 |
|
| 561 |
This makes bidict more efficient on Python 3 |
| 562 |
and enables further improvement to bidict in the future. |
| 563 |
|
| 564 |
- Deprecate ``bidict.OVERWRITE`` and ``bidict.IGNORE``. |
| 565 |
A :class:`UserWarning` will now be emitted if these are used. |
| 566 |
|
| 567 |
:attr:`bidict.DROP_OLD` and :attr:`bidict.DROP_NEW` should be used instead. |
| 568 |
|
| 569 |
- Rename ``DuplicationPolicy`` to :class:`~bidict.OnDupAction` |
| 570 |
(and implement it via an :class:`~enum.Enum`). |
| 571 |
|
| 572 |
An :class:`~bidict.OnDupAction` may be one of |
| 573 |
:attr:`~bidict.RAISE`, |
| 574 |
:attr:`~bidict.DROP_OLD`, or |
| 575 |
:attr:`~bidict.DROP_NEW`. |
| 576 |
|
| 577 |
- Expose the new :class:`~bidict.OnDup` class |
| 578 |
to contain the three :class:`~bidict.OnDupAction`\s |
| 579 |
that should be taken upon encountering |
| 580 |
the three kinds of duplication that can occur |
| 581 |
(*key*, *val*, *kv*). |
| 582 |
|
| 583 |
- Provide the |
| 584 |
:attr:`~bidict.ON_DUP_DEFAULT`, |
| 585 |
:attr:`~bidict.ON_DUP_RAISE`, and |
| 586 |
:attr:`~bidict.ON_DUP_DROP_OLD` |
| 587 |
:class:`~bidict.OnDup` convenience instances. |
| 588 |
|
| 589 |
- Deprecate the |
| 590 |
``on_dup_key``, ``on_dup_val``, and ``on_dup_kv`` arguments |
| 591 |
of :meth:`~bidict.MutableBidict.put` and :meth:`~bidict.MutableBidict.putall`. |
| 592 |
A :class:`UserWarning` will now be emitted if these are used. |
| 593 |
|
| 594 |
These have been subsumed by the new *on_dup* argument, |
| 595 |
which takes an :class:`~bidict.OnDup` instance. |
| 596 |
|
| 597 |
Use it like this: ``bi.put(1, 2, OnDup(key=RAISE, val=...))``. |
| 598 |
Or pass one of the instances already provided, |
| 599 |
such as :attr:`~bidict.ON_DUP_DROP_OLD`. |
| 600 |
Or just don't pass an *on_dup* argument |
| 601 |
to use the default value of :attr:`~bidict.ON_DUP_RAISE`. |
| 602 |
|
| 603 |
The :ref:`basic-usage:Values Must Be Unique` docs |
| 604 |
have been updated accordingly. |
| 605 |
|
| 606 |
- Deprecate the |
| 607 |
``on_dup_key``, ``on_dup_val``, and ``on_dup_kv`` |
| 608 |
:class:`~bidict.bidict` class attributes. |
| 609 |
A :class:`UserWarning` will now be emitted if these are used. |
| 610 |
|
| 611 |
These have been subsumed by the new |
| 612 |
:attr:`~bidict.BidictBase.on_dup` class attribute, |
| 613 |
which takes an :class:`~bidict.OnDup` instance. |
| 614 |
|
| 615 |
See the updated :doc:`extending` docs for example usage. |
| 616 |
|
| 617 |
- Improve the more efficient implementations of |
| 618 |
``bidict.BidirectionalMapping.keys``, |
| 619 |
``bidict.BidirectionalMapping.values``, and |
| 620 |
``bidict.BidirectionalMapping.items``, |
| 621 |
and now also provide a more efficient implementation of |
| 622 |
``bidict.BidirectionalMapping.__iter__`` |
| 623 |
by delegating to backing :class:`dict`\s |
| 624 |
in the bidict types for which this is possible. |
| 625 |
|
| 626 |
- Move |
| 627 |
:meth:`bidict.BidictBase.values` to |
| 628 |
``bidict.BidirectionalMapping.values``, |
| 629 |
since the implementation is generic. |
| 630 |
|
| 631 |
- No longer use ``__all__`` in :mod:`bidict`'s ``__init__.py``. |
| 632 |
|
| 633 |
|
| 634 |
0.18.4 (2020-11-02) |
| 635 |
------------------- |
| 636 |
|
| 637 |
- Backport fix from v0.20.0 |
| 638 |
that removes ``bidict.BidirectionalMapping.__subclasshook__`` |
| 639 |
due to lack of use and maintenance cost. |
| 640 |
|
| 641 |
|
| 642 |
0.18.3 (2019-09-22) |
| 643 |
------------------- |
| 644 |
|
| 645 |
- Improve validation of names passed to ``namedbidict``: |
| 646 |
Use :meth:`str.isidentifier` on Python 3, |
| 647 |
and a better regex on Python 2. |
| 648 |
|
| 649 |
- On Python 3, |
| 650 |
set :attr:`~definition.__qualname__` on ``namedbidict`` classes |
| 651 |
based on the provided ``typename`` argument. |
| 652 |
|
| 653 |
|
| 654 |
0.18.2 (2019-09-08) |
| 655 |
------------------- |
| 656 |
|
| 657 |
- Warn that Python 2 support will be dropped in a future release |
| 658 |
when Python 2 is detected. |
| 659 |
|
| 660 |
|
| 661 |
0.18.1 (2019-09-03) |
| 662 |
------------------- |
| 663 |
|
| 664 |
- Fix a regression introduced by the memory optimizations added in 0.15.0 |
| 665 |
which caused |
| 666 |
:func:`deepcopied <copy.deepcopy>` and |
| 667 |
:func:`unpickled <pickle.loads>` |
| 668 |
bidicts to have their inverses set incorrectly. |
| 669 |
:issue:`94` |
| 670 |
|
| 671 |
|
| 672 |
0.18.0 (2019-02-14) |
| 673 |
------------------- |
| 674 |
|
| 675 |
- Rename ``bidict.BidirectionalMapping.inv`` to :attr:`~bidict.BidirectionalMapping.inverse` |
| 676 |
and make :attr:`bidict.BidictBase.inv` an alias for :attr:`~bidict.BidictBase.inverse`. |
| 677 |
:issue:`86` |
| 678 |
|
| 679 |
- ``bidict.BidirectionalMapping.__subclasshook__`` now requires an ``inverse`` attribute |
| 680 |
rather than an ``inv`` attribute for a class to qualify as a virtual subclass. |
| 681 |
This breaking change is expected to affect few if any users. |
| 682 |
|
| 683 |
- Add Python 2/3-compatible ``bidict.compat.collections_abc`` alias. |
| 684 |
|
| 685 |
- Stop testing Python 3.4 on CI, |
| 686 |
and warn when Python 3 < 3.5 is detected |
| 687 |
rather than Python 3 < 3.3. |
| 688 |
|
| 689 |
Python 3.4 reaches `end of life <https://www.python.org/dev/peps/pep-0429/>`__ on 2019-03-18. |
| 690 |
As of January 2019, 3.4 represents only about 3% of bidict downloads on |
| 691 |
`PyPI Stats <https://pypistats.org/packages/bidict>`__. |
| 692 |
|
| 693 |
|
| 694 |
0.17.5 (2018-11-19) |
| 695 |
------------------- |
| 696 |
|
| 697 |
Improvements to performance and delegation logic, |
| 698 |
with minor breaking changes to semi-private APIs. |
| 699 |
|
| 700 |
- Remove the ``__delegate__`` instance attribute added in the previous release. |
| 701 |
It was overly general and not worth the cost. |
| 702 |
|
| 703 |
Instead of checking ``self.__delegate__`` and delegating accordingly |
| 704 |
each time a possibly-delegating method is called, |
| 705 |
revert back to using "delegated-to-fwdm" mixin classes |
| 706 |
(now found in ``bidict._delegating_mixins``), |
| 707 |
and resurrect a mutable bidict parent class that omits the mixins |
| 708 |
as :class:`bidict.MutableBidict`. |
| 709 |
|
| 710 |
- Rename ``__repr_delegate__`` to ``_repr_delegate``. |
| 711 |
|
| 712 |
|
| 713 |
0.17.4 (2018-11-14) |
| 714 |
------------------- |
| 715 |
|
| 716 |
Minor code, interop, and (semi-)private API improvements. |
| 717 |
|
| 718 |
- :class:`~bidict.OrderedBidict` optimizations and code improvements. |
| 719 |
|
| 720 |
Use ``bidict``\s for the backing ``_fwdm`` and ``_invm`` mappings, |
| 721 |
obviating the need to store key and value data in linked list nodes. |
| 722 |
|
| 723 |
- Refactor proxied- (i.e. delegated-) to-``_fwdm`` logic |
| 724 |
for better composability and interoperability. |
| 725 |
|
| 726 |
Drop the ``_Proxied*`` mixin classes |
| 727 |
and instead move their methods |
| 728 |
into :class:`~bidict.BidictBase`, |
| 729 |
which now checks for an object defined by the |
| 730 |
``BidictBase.__delegate__`` attribute. |
| 731 |
The ``BidictBase.__delegate__`` object |
| 732 |
will be delegated to if the method is available on it, |
| 733 |
otherwise a default implementation |
| 734 |
(e.g. inherited from :class:`~collections.abc.Mapping`) |
| 735 |
will be used otherwise. |
| 736 |
Subclasses may set ``__delegate__ = None`` to opt out. |
| 737 |
|
| 738 |
Consolidate ``_MutableBidict`` into :class:`bidict.bidict` |
| 739 |
now that the dropped mixin classes make it unnecessary. |
| 740 |
|
| 741 |
- Change ``__repr_delegate__`` |
| 742 |
to simply take a type like :class:`dict` or :class:`list`. |
| 743 |
|
| 744 |
- Upgrade to latest major |
| 745 |
`sortedcontainers <https://github.com/grantjenks/python-sortedcontainers>`__ |
| 746 |
version (from v1 to v2) |
| 747 |
for the :ref:`extending:\`\`SortedBidict\`\` Recipes`. |
| 748 |
|
| 749 |
- ``bidict.compat.{view,iter}{keys,values,items}`` on Python 2 |
| 750 |
no longer assumes the target object implements these methods, |
| 751 |
as they're not actually part of the |
| 752 |
:class:`~collections.abc.Mapping` interface, |
| 753 |
and provides fallback implementations when the methods are unavailable. |
| 754 |
This allows the :ref:`extending:\`\`SortedBidict\`\` Recipes` |
| 755 |
to continue to work with sortedcontainers v2 on Python 2. |
| 756 |
|
| 757 |
|
| 758 |
0.17.3 (2018-09-18) |
| 759 |
------------------- |
| 760 |
|
| 761 |
- Improve packaging by adding a pyproject.toml |
| 762 |
and by including more supporting files in the distribution. |
| 763 |
`#81 <https://github.com/jab/bidict/pull/81>`__ |
| 764 |
|
| 765 |
- Drop pytest-runner and support for running tests via ``python setup.py test`` |
| 766 |
in preference to ``pytest`` or ``python -m pytest``. |
| 767 |
|
| 768 |
|
| 769 |
0.17.2 (2018-04-30) |
| 770 |
------------------- |
| 771 |
|
| 772 |
**Memory usage improvements** |
| 773 |
|
| 774 |
- Use less memory in the linked lists that back |
| 775 |
:class:`~bidict.OrderedBidict`\s |
| 776 |
by storing node data unpacked |
| 777 |
rather than in (key, value) tuple objects. |
| 778 |
|
| 779 |
|
| 780 |
0.17.1 (2018-04-28) |
| 781 |
------------------- |
| 782 |
|
| 783 |
**Bugfix Release** |
| 784 |
|
| 785 |
Fix a regression in 0.17.0 that could cause erroneous behavior |
| 786 |
when updating items of an :class:`~bidict.OrderedBidict`'s inverse, |
| 787 |
e.g. ``some_ordered_bidict.inv[foo] = bar``. |
| 788 |
|
| 789 |
|
| 790 |
0.17.0 (2018-04-25) |
| 791 |
------------------- |
| 792 |
|
| 793 |
**Speedups and memory usage improvements** |
| 794 |
|
| 795 |
- Pass |
| 796 |
:meth:`~bidict.BidictBase.keys`, |
| 797 |
:meth:`~bidict.BidictBase.values`, and |
| 798 |
:meth:`~bidict.BidictBase.items` calls |
| 799 |
(as well as their ``iter*`` and ``view*`` counterparts on Python 2) |
| 800 |
through to the backing ``_fwdm`` and ``_invm`` dicts |
| 801 |
so that they run as fast as possible |
| 802 |
(i.e. at C speed on CPython), |
| 803 |
rather than using the slower implementations |
| 804 |
inherited from :class:`collections.abc.Mapping`. |
| 805 |
|
| 806 |
- Use weakrefs in the linked lists that back |
| 807 |
:class:`~bidict.OrderedBidict`\s |
| 808 |
to avoid creating strong reference cycles. |
| 809 |
|
| 810 |
Memory for an ordered bidict that you create |
| 811 |
can now be reclaimed in CPython |
| 812 |
as soon as you no longer hold any references to it, |
| 813 |
rather than having to wait until the next garbage collection. |
| 814 |
`#71 <https://github.com/jab/bidict/pull/71>`__ |
| 815 |
|
| 816 |
|
| 817 |
**Misc** |
| 818 |
|
| 819 |
- Add ``bidict.__version_info__`` attribute |
| 820 |
to complement ``bidict.__version__``. |
| 821 |
|
| 822 |
|
| 823 |
0.16.0 (2018-04-06) |
| 824 |
------------------- |
| 825 |
|
| 826 |
Minor code and efficiency improvements to |
| 827 |
:func:`~bidict.inverted` and |
| 828 |
``bidict._iter._iteritems_args_kw`` |
| 829 |
(formerly ``bidict.pairs()``). |
| 830 |
|
| 831 |
|
| 832 |
**Minor Breaking API Changes** |
| 833 |
|
| 834 |
The following breaking changes are expected to affect few if any users. |
| 835 |
|
| 836 |
- Rename ``bidict.pairs()`` → ``bidict._iter._iteritems_args_kw``. |
| 837 |
|
| 838 |
|
| 839 |
0.15.0 (2018-03-29) |
| 840 |
------------------- |
| 841 |
|
| 842 |
**Speedups and memory usage improvements** |
| 843 |
|
| 844 |
- Use :ref:`slots` to speed up bidict attribute access and reduce memory usage. |
| 845 |
On Python 3, |
| 846 |
instantiating a large number of bidicts now uses ~57% the amount of memory |
| 847 |
that it used before, |
| 848 |
and on Python 2 only ~33% the amount of memory that it used before, |
| 849 |
in a simple but representative |
| 850 |
`benchmark <https://github.com/jab/bidict/pull/56#issuecomment-368203591>`__. |
| 851 |
|
| 852 |
- Use weakrefs to refer to a bidict's inverse internally, |
| 853 |
no longer creating a strong reference cycle. |
| 854 |
Memory for a bidict that you create can now be reclaimed |
| 855 |
in CPython as soon as you no longer hold any references to it, |
| 856 |
rather than having to wait for the next garbage collection. |
| 857 |
See the new |
| 858 |
:ref:`addendum:\`\`bidict\`\` Avoids Reference Cycles` |
| 859 |
documentation. |
| 860 |
:issue:`24` |
| 861 |
|
| 862 |
- Make :func:`bidict.BidictBase.__eq__` significantly |
| 863 |
more speed- and memory-efficient when comparing to |
| 864 |
a non-:class:`dict` :class:`~collections.abc.Mapping`. |
| 865 |
(``Mapping.__eq__()``\'s inefficient implementation will now never be used.) |
| 866 |
The implementation is now more reusable as well. |
| 867 |
|
| 868 |
- Make :func:`bidict.OrderedBidictBase.__iter__` as well as |
| 869 |
equality comparison slightly faster for ordered bidicts. |
| 870 |
|
| 871 |
**Minor Bugfixes** |
| 872 |
|
| 873 |
- ``namedbidict`` now verifies that the provided |
| 874 |
``keyname`` and ``valname`` are distinct, |
| 875 |
raising :class:`ValueError` if they are equal. |
| 876 |
|
| 877 |
- ``namedbidict`` now raises :class:`TypeError` |
| 878 |
if the provided ``base_type`` |
| 879 |
is not a :class:`~bidict.BidirectionalMapping`. |
| 880 |
|
| 881 |
- If you create a custom bidict subclass whose ``_fwdm_cls`` |
| 882 |
differs from its ``_invm_cls`` |
| 883 |
(as in the ``FwdKeySortedBidict`` example |
| 884 |
from the :ref:`extending:\`\`SortedBidict\`\` Recipes`), |
| 885 |
the inverse bidirectional mapping type |
| 886 |
(with ``_fwdm_cls`` and ``_invm_cls`` swapped) |
| 887 |
is now correctly computed and used automatically |
| 888 |
for your custom bidict's |
| 889 |
:attr:`~bidict.BidictBase.inverse` bidict. |
| 890 |
|
| 891 |
**Misc** |
| 892 |
|
| 893 |
- Classes no longer have to provide an ``__inverted__`` |
| 894 |
attribute to be considered virtual subclasses of |
| 895 |
:class:`~bidict.BidirectionalMapping`. |
| 896 |
|
| 897 |
- If :func:`bidict.inverted` is passed |
| 898 |
an object with an ``__inverted__`` attribute, |
| 899 |
it now ensures it is :func:`callable` |
| 900 |
before returning the result of calling it. |
| 901 |
|
| 902 |
- :func:`~bidict.BidictBase.__repr__` no longer checks for a ``__reversed__`` |
| 903 |
method to determine whether to use an ordered or unordered-style repr. |
| 904 |
It now calls the new ``__repr_delegate__`` instead |
| 905 |
(which may be overridden if needed), for better composability. |
| 906 |
|
| 907 |
**Minor Breaking API Changes** |
| 908 |
|
| 909 |
The following breaking changes are expected to affect few if any users. |
| 910 |
|
| 911 |
- Split back out the :class:`~bidict.BidictBase` class |
| 912 |
from :class:`~bidict.frozenbidict` |
| 913 |
and :class:`~bidict.OrderedBidictBase` |
| 914 |
from ``FrozenOrderedBidict``, |
| 915 |
reverting the merging of these in 0.14.0. |
| 916 |
Having e.g. ``issubclass(bidict, frozenbidict) == True`` was confusing, |
| 917 |
so this change restores ``issubclass(bidict, frozenbidict) == False``. |
| 918 |
|
| 919 |
See the updated :ref:`other-bidict-types:Bidict Types Diagram` |
| 920 |
and :ref:`other-bidict-types:Polymorphism` documentation. |
| 921 |
|
| 922 |
- Rename: |
| 923 |
|
| 924 |
- ``bidict.BidictBase.fwdm`` → ``._fwdm`` |
| 925 |
- ``bidict.BidictBase.invm`` → ``._invm`` |
| 926 |
- ``bidict.BidictBase.fwd_cls`` → ``._fwdm_cls`` |
| 927 |
- ``bidict.BidictBase.inv_cls`` → ``._invm_cls`` |
| 928 |
- ``bidict.BidictBase.isinv`` → ``._isinv`` |
| 929 |
|
| 930 |
Though overriding ``_fwdm_cls`` and ``_invm_cls`` remains supported |
| 931 |
(see :doc:`extending`), |
| 932 |
this is not a common enough use case to warrant public names. |
| 933 |
Most users do not need to know or care about any of these. |
| 934 |
|
| 935 |
- The :attr:`~bidict.RAISE`, |
| 936 |
``OVERWRITE``, and ``IGNORE`` |
| 937 |
duplication policies are no longer available as attributes of |
| 938 |
``DuplicationPolicy``, |
| 939 |
and can now only be accessed as attributes of |
| 940 |
the :mod:`bidict` module namespace, |
| 941 |
which was the canonical way to refer to them anyway. |
| 942 |
It is now no longer possible to create an infinite chain like |
| 943 |
``DuplicationPolicy.RAISE.RAISE.RAISE...`` |
| 944 |
|
| 945 |
- Make ``bidict.pairs()`` and :func:`bidict.inverted` |
| 946 |
no longer importable from ``bidict.util``, |
| 947 |
and now only importable from the top-level :mod:`bidict` module. |
| 948 |
(``bidict.util`` was renamed ``bidict._util``.) |
| 949 |
|
| 950 |
- Pickling ordered bidicts now requires |
| 951 |
at least version 2 of the pickle protocol. |
| 952 |
If you are using Python 3, |
| 953 |
:obj:`pickle.DEFAULT_PROTOCOL` is 3 anyway, |
| 954 |
so this will not affect you. |
| 955 |
However if you are using in Python 2, |
| 956 |
:obj:`~pickle.DEFAULT_PROTOCOL` is 0, |
| 957 |
so you must now explicitly specify the version |
| 958 |
in your :func:`pickle.dumps` calls, |
| 959 |
e.g. ``pickle.dumps(ob, 2)``. |