Bidict

Latest version: v0.23.1

Safety actively analyzes 629564 Python packages for vulnerabilities to keep your Python projects secure.

Scan your dependencies

Page 4 of 4

0.17.3

-------------------

- Improve packaging by adding a pyproject.toml
and by including more supporting files in the distribution.
`81 <https://github.com/jab/bidict/pull/81>`__

- Drop pytest-runner and support for running tests via ``python setup.py test``
in preference to ``pytest`` or ``python -m pytest``.

0.17.2

-------------------

**Memory usage improvements**

- Use less memory in the linked lists that back
:class:`~bidict.OrderedBidict`\s
by storing node data unpacked
rather than in (key, value) tuple objects.

0.17.1

-------------------

**Bugfix Release**

Fix a regression in 0.17.0 that could cause erroneous behavior
when updating items of an :class:`~bidict.OrderedBidict`'s inverse,
e.g. ``some_ordered_bidict.inv[foo] = bar``.

0.17.0

-------------------

**Speedups and memory usage improvements**

- Pass
:meth:`~bidict.BidictBase.keys`,
:meth:`~bidict.BidictBase.values`, and
:meth:`~bidict.BidictBase.items` calls
(as well as their ``iter*`` and ``view*`` counterparts on Python 2)
through to the backing ``_fwdm`` and ``_invm`` dicts
so that they run as fast as possible
(i.e. at C speed on CPython),
rather than using the slower implementations
inherited from :class:`collections.abc.Mapping`.

- Use weakrefs in the linked lists that back
:class:`~bidict.OrderedBidict`\s
to avoid creating strong reference cycles.

Memory for an ordered bidict that you create
can now be reclaimed in CPython
as soon as you no longer hold any references to it,
rather than having to wait until the next garbage collection.
`71 <https://github.com/jab/bidict/pull/71>`__


**Misc**

- Add ``bidict.__version_info__`` attribute
to complement :attr:`bidict.__version__`.

0.16.0

-------------------

Minor code and efficiency improvements to
:func:`~bidict.inverted` and
``bidict._iter._iteritems_args_kw``
(formerly ``bidict.pairs()``).


**Minor Breaking API Changes**

The following breaking changes are expected to affect few if any users.

- Rename ``bidict.pairs()`` → ``bidict._iter._iteritems_args_kw``.

0.15.0

-------------------

**Speedups and memory usage improvements**

- Use :ref:`slots` to speed up bidict attribute access and reduce memory usage.
On Python 3,
instantiating a large number of bidicts now uses ~57% the amount of memory
that it used before,
and on Python 2 only ~33% the amount of memory that it used before,
in a simple but representative
`benchmark <https://github.com/jab/bidict/pull/56#issuecomment-368203591>`__.

- Use weakrefs to refer to a bidict's inverse internally,
no longer creating a strong reference cycle.
Memory for a bidict that you create can now be reclaimed
in CPython as soon as you no longer hold any references to it,
rather than having to wait for the next garbage collection.
See the new
:ref:`addendum:\`\`bidict\`\` Avoids Reference Cycles`
documentation.
:issue:`24`

- Make :func:`bidict.BidictBase.__eq__` significantly
more speed- and memory-efficient when comparing to
a non-:class:`dict` :class:`~collections.abc.Mapping`.
(``Mapping.__eq__()``\'s inefficient implementation will now never be used.)
The implementation is now more reusable as well.

- Make :func:`bidict.OrderedBidictBase.__iter__` as well as
equality comparison slightly faster for ordered bidicts.

**Minor Bugfixes**

- ``namedbidict`` now verifies that the provided
``keyname`` and ``valname`` are distinct,
raising :class:`ValueError` if they are equal.

- ``namedbidict`` now raises :class:`TypeError`
if the provided ``base_type``
is not a :class:`~bidict.BidirectionalMapping`.

- If you create a custom bidict subclass whose ``_fwdm_cls``
differs from its ``_invm_cls``
(as in the ``FwdKeySortedBidict`` example
from the :ref:`extending:\`\`SortedBidict\`\` Recipes`),
the inverse bidirectional mapping type
(with ``_fwdm_cls`` and ``_invm_cls`` swapped)
is now correctly computed and used automatically
for your custom bidict's
:attr:`~bidict.BidictBase.inverse` bidict.

**Misc**

- Classes no longer have to provide an ``__inverted__``
attribute to be considered virtual subclasses of
:class:`~bidict.BidirectionalMapping`.

- If :func:`bidict.inverted` is passed
an object with an ``__inverted__`` attribute,
it now ensures it is :func:`callable`
before returning the result of calling it.

- :func:`~bidict.BidictBase.__repr__` no longer checks for a ``__reversed__``
method to determine whether to use an ordered or unordered-style repr.
It now calls the new ``__repr_delegate__`` instead
(which may be overridden if needed), for better composability.

**Minor Breaking API Changes**

The following breaking changes are expected to affect few if any users.

- Split back out the :class:`~bidict.BidictBase` class
from :class:`~bidict.frozenbidict`
and :class:`~bidict.OrderedBidictBase`
from ``FrozenOrderedBidict``,
reverting the merging of these in 0.14.0.
Having e.g. ``issubclass(bidict, frozenbidict) == True`` was confusing,
so this change restores ``issubclass(bidict, frozenbidict) == False``.

See the updated :ref:`other-bidict-types:Bidict Types Diagram`
and :ref:`other-bidict-types:Polymorphism` documentation.

- Rename:

- ``bidict.BidictBase.fwdm`` → ``._fwdm``
- ``bidict.BidictBase.invm`` → ``._invm``
- ``bidict.BidictBase.fwd_cls`` → ``._fwdm_cls``
- ``bidict.BidictBase.inv_cls`` → ``._invm_cls``
- ``bidict.BidictBase.isinv`` → ``._isinv``

Though overriding ``_fwdm_cls`` and ``_invm_cls`` remains supported
(see :doc:`extending`),
this is not a common enough use case to warrant public names.
Most users do not need to know or care about any of these.

- The :attr:`~bidict.RAISE`,
``OVERWRITE``, and ``IGNORE``
duplication policies are no longer available as attributes of
``DuplicationPolicy``,
and can now only be accessed as attributes of
the :mod:`bidict` module namespace,
which was the canonical way to refer to them anyway.
It is now no longer possible to create an infinite chain like
``DuplicationPolicy.RAISE.RAISE.RAISE...``

- Make ``bidict.pairs()`` and :func:`bidict.inverted`
no longer importable from ``bidict.util``,
and now only importable from the top-level :mod:`bidict` module.
(``bidict.util`` was renamed ``bidict._util``.)

- Pickling ordered bidicts now requires
at least version 2 of the pickle protocol.
If you are using Python 3,
:obj:`pickle.DEFAULT_PROTOCOL` is 3 anyway,
so this will not affect you.
However if you are using in Python 2,
:obj:`~pickle.DEFAULT_PROTOCOL` is 0,
so you must now explicitly specify the version
in your :func:`pickle.dumps` calls,
e.g. ``pickle.dumps(ob, 2)``.

Page 4 of 4

© 2024 Safety CLI Cybersecurity Inc. All Rights Reserved.