Message394884
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. |
|
Date |
User |
Action |
Args |
2021-06-02 02:47:58 | Dennis Sweeney | set | recipients:
+ Dennis Sweeney, rhettinger, brandtbucher |
2021-06-02 02:47:58 | Dennis Sweeney | set | messageid: <1622602078.8.0.0671688357518.issue44283@roundup.psfhosted.org> |
2021-06-02 02:47:58 | Dennis Sweeney | link | issue44283 messages |
2021-06-02 02:47:58 | Dennis Sweeney | create | |
|