2018-01-02 21:49:34 +00:00
|
|
|
:class:`~bidict.frozenbidict`
|
2018-03-27 07:35:52 +00:00
|
|
|
-----------------------------
|
2015-03-22 18:21:15 +00:00
|
|
|
|
2018-03-27 07:35:52 +00:00
|
|
|
:class:`~bidict.frozenbidict`
|
|
|
|
is an immutable, hashable bidirectional mapping type.
|
2018-02-26 23:29:56 +00:00
|
|
|
|
2015-03-22 18:21:15 +00:00
|
|
|
As you would expect,
|
2017-11-20 03:24:08 +00:00
|
|
|
attempting to mutate a
|
2018-01-02 21:49:34 +00:00
|
|
|
:class:`~bidict.frozenbidict`
|
2018-02-26 23:29:56 +00:00
|
|
|
causes an error::
|
2015-03-22 18:21:15 +00:00
|
|
|
|
2017-11-20 03:24:08 +00:00
|
|
|
>>> from bidict import frozenbidict
|
|
|
|
>>> f = frozenbidict({'H': 'hydrogen'})
|
2015-03-22 18:21:15 +00:00
|
|
|
>>> f['C'] = 'carbon'
|
|
|
|
Traceback (most recent call last):
|
2015-12-21 03:05:20 +00:00
|
|
|
...
|
2018-02-27 13:09:57 +00:00
|
|
|
TypeError: ...
|
|
|
|
|
2015-03-22 18:21:15 +00:00
|
|
|
|
2018-01-02 21:49:34 +00:00
|
|
|
:class:`~bidict.frozenbidict`
|
2017-11-20 03:24:08 +00:00
|
|
|
also implements :class:`collections.abc.Hashable`,
|
|
|
|
so it's suitable for insertion into sets or other mappings::
|
2015-03-22 18:21:15 +00:00
|
|
|
|
2018-03-27 07:35:52 +00:00
|
|
|
>>> my_set = {f} # not an error
|
|
|
|
>>> my_dict = {f: 1} # also not an error
|
squashed changes for 0.13.0
- support Python 3.6, refactor CI/test setup, increase test coverage
- refactor BidirectionalMapping, BidictBase, OrderedBidictBase,
FrozenBidictBase, and subclasses
- move frozenorderedbidict into _frozen and looseorderedbidict into _loose
- register bidict as a virtual subclass of MutableMapping rather than
inheriting from it directly. This makes it clearer that it does not use any
of the concrete generic methods that MutableMapping provides.
- improve performance and flexibility of frozenbidict and
frozenorderedbidict hashing
- docs, including new type-hierarchy.png diagram
- rm unused imap, ifilter, izip_longest from compat, add PYPY
- update to latest versions of dependencies
- restore benchmarking on travis
2017-01-09 15:37:31 +00:00
|
|
|
|
2018-01-02 21:49:34 +00:00
|
|
|
See the :class:`~bidict.frozenbidict`
|
2017-11-20 03:24:08 +00:00
|
|
|
API documentation for more information.
|