Skip to content

Bug in nmod hash #373

@ForeverHaibara

Description

@ForeverHaibara

Tested on python 3.14, flint 0.8.0.

I observe that

>>> from flint import nmod
>>> a = nmod(1,7)
>>> hash(a)==hash(nmod(1,7))
False
>>> hash(nmod(1,7))==hash(nmod(1,7))
True
>>> a == nmod(1,7)
True

a and nmod(1,7) got different hash values.

After some conversations with Gemini, it seems in nmod.pyx:

    def __hash__(self):
        return hash((int(self.val), self.modulus))

which in fact should be self.modulus() since it is a method, not a property.

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