2

I want to have consistent hash values in Python using the built in hash function. I thus want to set the environmental variable PYTHONHASHSEED to a number, as documented in https://docs.python.org/3/using/cmdline.html , to over-ride the randomization. How is this possible on windows? (most of the instructions i have seen, e.g., export PYTHONHASHSEED=100 seem to be for Linux).

I have tried adding PYTHONHASHSEED with a number under environmental variables (in system properties), but the number from the hash function when i run python still changes every time.

kyrenia
  • 5,431
  • 9
  • 63
  • 93
  • `setx export PYTHONHASHSEED 100` ... or `set PYTHONHASHSEED=100` in your terminal. This isn't really a python question, there's a very good dupe target, though. – Jean-François Fabre Mar 23 '18 at 16:00
  • Note that setting the `PYTHONHASHSEED` won't *guarantee* you consistent hash values for all types, for example, not necessarily for integers https://stackoverflow.com/questions/44324494/equivalent-to-pythons-r-option-that-affects-the-hash-of-ints – Chris_Rands Mar 23 '18 at 16:05
  • @Chris_Rands hash of a small integer is itself IIRC (except for -1 => -2) – Jean-François Fabre Mar 23 '18 at 16:50

0 Answers0