Skip to content

hash(-1) is not behaving as expected #127814

@Dyr-El

Description

@Dyr-El

Bug report

Bug description:

Of all integers I have tested (looped through a couple of millions) all tend to have the same value of hash as themselves (hash(i) == i) except for i == -1. (There might be some reason for this but it makes for some strange behaviour. For me it meant that hash((4, -1)) == hash((4, -2)) which was rather unexpected.)

assert hash(-1) == -2

CPython versions tested on:

3.9, 3.12

Operating systems tested on:

Linux, Windows

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions