Pygtrie

Latest version: v2.5.0

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

Scan your dependencies

Page 1 of 3

2.5

- Add :func:`pygtrie.Trie.merge` method which merges structures of two
tries.

- Add :func:`pygtrie.Trie.strictly_equals` method which compares two
tries with stricter rules than regular equality operator. It’s not
sufficient that keys and values are the same but the structure of
the tries must be the same as well. For example:

>>> t0 = StringTrie({'foo/bar.baz': 42}, separator='/')
>>> t1 = StringTrie({'foo/bar.baz': 42}, separator='.')
>>> t0 == t1
True
>>> t0.strictly_equals(t1)
False

- Fix :func:`pygtrie.Trie.__eq__` implementation such that key values
are taken into consideration rather than just looking at trie
structure. To see what this means it’s best to look at a few
examples. Firstly:

>>> t0 = StringTrie({'foo/bar': 42}, separator='/')
>>> t1 = StringTrie({'foo.bar': 42}, separator='.')
>>> t0 == t1
False

This used to be true since the two tries have the same node
structure. However, as far as Mapping interface is concerned, they
use different keys, i.e. set(t0) != set(t1)``. Secondly:

>>> t0 = StringTrie({'foo/bar.baz': 42}, separator='/')
>>> t1 = StringTrie({'foo/bar.baz': 42}, separator='.')
>>> t0 == t1
True

This used to be false since the two tries have different node
structures (the first one splits key into ``('foo', 'bar.baz')``
while the second into ``('foo/bar', 'baz')``). However, their keys
are the same, i.e. set(t0) == set(t1)``. And lastly:

>>> t0 = Trie({'foo': 42})
>>> t1 = CharTrie({'foo': 42})
>>> t0 == t1
False

This used to be true since the two tries have the same node
structure. However, the two classes return key as different values.
:class:`pygtrie.Trie` returns keys as tuples while
:class:`pygtrie.CharTrie` returns them as strings.

2.4.2

- Remove use of ‘super’ in ``setup.py`` to fix compatibility with
Python 2.7. This changes build code only; no changes to the library
itself.

2.4.1

- Remove dependency on ``packaging`` module from ``setup.py`` to fix
installation on systems without that package. This changes build
code only; no changes to the library itself. [Thanks to Eric
McLachlan for reporting]

2.4.0

- Change ``children`` argument of the ``node_factory`` passed to
:func:`pygtrie.Trie.traverse` from a generator to an iterator with
a custom bool conversion. This allows checking whether node has
children without having to iterate over them (``bool(children)``)

To test whether this feature is available, one can check whether
`Trie.traverse.uses_bool_convertible_children` property is true,
e.g.: ``getattr(pygtrie.Trie.traverse,
'uses_bool_convertible_children', False)``.

[Thanks to Pallab Pain for suggesting the feature]

2.3.3

- Fix to ‘:class:`AttributeError`: ``_NoChildren`` object has no
attribute ``sorted_items``’ failure when iterating over a trie with
sorting enabled. [Thanks to Pallab Pain for reporting]

- Add ``value`` property setter to step objects returned by
:func:`pygtrie.Trie.walk_towards` et al. This deprecates the
``set`` method.

- The module now exports `pygtrie.__version__` making it possible to
determine version of the library at run-time.

2.3.2

- Trivial metadata fix

Page 1 of 3

© 2024 Safety CLI Cybersecurity Inc. All Rights Reserved.