set arbitrary hash random seed to ensure reproducible results
Hi, I am wondering if it would be good to add an additional keyword `seed` to the builtin function *hash* to allow us to set arbitrary seed to ensure reproducible results. As far as I know, there exists already the environment variable PYTHONHASHSEED that allows us to set arbitrary seed or disable the seed globally for the python interpreter. However, it looks like that it would be too bold to use that environment variable to change the default behavior because the random seed generation helps improve the security my reducing the risk of hash flooding. In parallel, we have identified a couple of real use cases that require that an arbitrary seed is used for a limited scope. For instance, if we create a caching programming interface that relies on a distributed kv store, it would be very important to make sure that the hash key stays the same when the application is rebooted or replicated. It is generally more cautious to use the above capability to limit the scope to the caching library itself instead of applying the same for all the hash functions of all the python interpreters. WDYT? Kind regards, Hao
participants (4)
-
Chris Angelico
-
Hao Hu
-
Stephen J. Turnbull
-
Steven D'Aprano