Dennis Sweeney <[email protected]> added the comment:
At first I thought of matches with only the int/str/None cases and then I saw
the easy generalization, but yeah, each contiguous block seems better.
One solution to the code hashability/lookup speed apparent dilemma: writing the
equivalent of this in C:
class HashableDict(dict):
def __new__(cls, pairs):
return dict.__new__(cls, pairs)
def __eq__(self, other):
return tuple(self.mapping.items()) == tuple(other.sequence.items())
def __hash__(self):
return CONSTANT ^ hash(tuple(self.items()))
def __getnewargs__(self):
return tuple(self.items())
# forbid all mutating methods
__setitem__ = __delitem__ = update = __ior__ = None # etc.
(Or maybe using composition rather than inheritence)
Maybe using the HAMT in /Python/hamt.c would suffice instead.
----------
_______________________________________
Python tracker <[email protected]>
<https://bugs.python.org/issue44283>
_______________________________________
_______________________________________________
Python-bugs-list mailing list
Unsubscribe:
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com