This issue tracker has been migrated to GitHub, and is currently read-only.
For more information, see the GitHub FAQs in the Python's Developer Guide.

Author Dennis Sweeney
Recipients Dennis Sweeney, brandtbucher, rhettinger
Date 2021-06-02.02:47:58
SpamBayes Score -1.0
Marked as misclassified Yes
Message-id <1622602078.8.0.0671688357518.issue44283@roundup.psfhosted.org>
In-reply-to
Content
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.
History
Date User Action Args
2021-06-02 02:47:58Dennis Sweeneysetrecipients: + Dennis Sweeney, rhettinger, brandtbucher
2021-06-02 02:47:58Dennis Sweeneysetmessageid: <1622602078.8.0.0671688357518.issue44283@roundup.psfhosted.org>
2021-06-02 02:47:58Dennis Sweeneylinkissue44283 messages
2021-06-02 02:47:58Dennis Sweeneycreate