Skip to content

Hashing NOTHING in CPython is 60% slower than it should be on 32 bit builds #331

@mr-nfamous

Description

@mr-nfamous
class DeadBeef:
    def __hash__(self):
        return 0xdeadbeef

class LeetBeef:
    def __hash__(self):
        return 0x5eadbef0

a = Timer('hash(self)', 'from __main__ import DeadBeef;self=DeadBeef()')
b = Timer('hash(self)', 'from __main__ import LeetBeef;self=LeetBeef()')

print('Dead:', hex(hash(DeadBeef())), min(a.repeat()))
print('Leet:', hex(hash(LeetBeef())), min(b.repeat()))

Don't know how/want to learn how to contribute to projects on here, but I would feel bad if I didn't at least mention on here an oversight of this magnitude.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions