0

I found this in pyhash.h. I know _PyHASH_MULTIPLIER is prime multiplier used for hashing but I just want to the rationale behind that prime number. I searched PEPs but didn't get anything constructive.

Thank you.

Siddharth
  • 526
  • 1
  • 8
  • 15
  • 1
    in theory, using a prime reduces the number of collisions. which you could find with a quick search...first hit: https://computinglife.wordpress.com/2008/11/20/why-do-hash-functions-use-prime-numbers/ , https://stackoverflow.com/questions/1145217/why-should-hash-functions-use-a-prime-number-modulus , https://cs.stackexchange.com/questions/11029/why-is-it-best-to-use-a-prime-number-as-a-mod-in-a-hashing-function – Mitch Wheat Mar 07 '18 at 07:58
  • @MitchWheat My question is related with python. I know the theory. Are you implying that it is random choice and any prime will do? – Siddharth Mar 07 '18 at 08:24

0 Answers0