HashMap[K, V]: an immutable map whose keys compare as Effect's
Equal.equals does (Effect's HashMap).
A dict keys by == and hash: it calls 1 and True one key,
a NaN never equal to itself and a list or dict unhashable. A HashMap
keys by pyfect._equal.equal_key: True stays apart from 1, NaN
finds NaN, and lists, tuples, dicts and sets are keys by their items::
m = HashMap.make((["a", 1], "x"), (True, "y"))
m.get(["a", 1]) # Some("x")
m.get(1) # None
m2 = m.set(1, "z") # a new map; m is unchangedEvery update returns a new map and leaves the old one as it was. Like
Effect's, the map is a persistent hash array mapped trie (pyfect._hamt):
an update copies about log32(size) nodes and shares the rest.
Iteration yields (key, value) pairs in hash order, Effect's order: keys
are hashed with Effect's Hash.hash (pyfect._effect_hash).
The hash arguments of get_hash / has_hash / modify_hash are
accepted for Effect's API and not needed: keys are found by value.
Classes#
On This Page
Classes