Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Trac #27914: py3: hash collisions of Laurent polynomials
This ticket adjusts the hash of multivariate Laurent polynomials, so that it agrees with the hash of univariate Laurent polynomials. This solves the following problem: Using Python 3, this doctest in `laurent_polynomial.pyx` fails about 1 out of 4 times. {{{ sage: L.<w,z> = LaurentPolynomialRing(QQ) sage: len({hash(w^i*z^j) for i in [-2..2] for j in [-2..2]}) 25 }}} Due to hash collisions, the result can be smaller than 25 (such as 23 or 21). This gets even worse when using a larger range of monomials. Regardless of that, it is desirable that univariate and multivariate Laurent polynomials have the same hash anyway. The univariate hash implementation does not seem to have these collisions, so adopting that implementation solves this problem. For reference, the univariate and multivariate hashes were implemented in #21272 and #23864. URL: https://trac.sagemath.org/27914 Reported by: gh-mwageringel Ticket author(s): Markus Wageringel Reviewer(s): Frédéric Chapoton
- Loading branch information