1 pyutils.collectionz package
2 ===========================
7 pyutils.collectionz.bidict module
8 ---------------------------------
10 The bidict.BiDict class is a subclass of :py:class:`dict` that
11 implements a bidirectional dictionary. That is, it maps each key to a
12 value in constant time and each value back to the one or more keys it
13 is associated with in constant time. It does this by simply storing
18 # Initialize with a normal dict...
19 third_party_wierdos = BiDict({
20 'prometheus-fastapi-instrumentator': 'prometheus_fastapi_instrumentator',
21 'scikit-learn': 'sklearn',
22 'antlr4-python3-runtime' : 'antlr4',
23 'python-dateutil': 'dateutil',
24 'speechrecognition': 'speech_recognition',
25 'beautifulsoup4': 'bs4',
26 'python-dateutil': 'dateutil',
27 'homeassistant-api': 'homeassistant_api',
30 # Use in one direction:
31 x = third_party_wierdos['scikit-learn']
33 # Use in opposite direction:
34 y = third_party_wierdos.inverse['python_dateutil']
36 # Note: type(y) is List since one value may map back to multiple keys.
39 .. automodule:: pyutils.collectionz.bidict
44 pyutils.collectionz.bst module
45 ------------------------------
47 The bst.BinarySearchTree class is a binary search tree container.
49 .. automodule:: pyutils.collectionz.bst
54 pyutils.collectionz.shared\_dict module
55 ---------------------------------------
57 The shared\_dict.SharedDict class is a normal python dictionary that
58 can be accessed safely in parallel from multiple threads or processes
59 without (external) locking by using Multiprocessing.SharedMemory. It
60 uses internal locking and rewrites the shared memory region as it is
61 changed so it is slower than a normal dict. It also does not grow
62 dynamically; the creator of the shared\_dict must declare a maximum
65 .. automodule:: pyutils.collectionz.shared_dict
70 pyutils.collectionz.trie module
71 -------------------------------
73 The trie.Trie class is a Trie or prefix tree. It can be used with
74 arbitrary sequences as keys and stores its values in a tree with paths
75 determined by the sequence determined by each key. Thus, it can
76 determine whether a value is contained in the tree via a simple
77 traversal in linear time and can also check whether a key-prefix is
78 present in the tree in linear time.
80 .. automodule:: pyutils.collectionz.trie
88 .. automodule:: pyutils.collectionz