> On 17 Dec 2021, at 15:42, Steven D'Aprano <st...@pearwood.info> wrote:
>
> On Fri, Dec 17, 2021 at 02:07:38PM -0000, Hao Hu wrote:
>> 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.
>
> I assume you are talking about hashing strings, I believe they are the
> only objects that are effected by hash randomization.
I am not sure about this, though I agree with you that strings are affected by
this.
>
>
>> 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.
>
> Does your distributed key/value store have to use the built-in hash
> function?
If you limit the use case strictly to a string and a value, I agree with you
that I can rely on the hashing capability of the kv store.
However, sometimes I expect something more generic, such as it might be a tuple
that mixes numbers, strings and other hashable types at least.
Another option might be using serialisation to produce key, but there are 2
things to tackle
- serialisation vs hash in terms of speed
- a key of dynamic size vs key of fixed size (I tend to believe that fixed size
key is more friendly for random access on kv storage side)
>
>
> --
> Steve
> _______________________________________________
> Python-ideas mailing list -- python-ideas@python.org
> To unsubscribe send an email to python-ideas-le...@python.org
> https://mail.python.org/mailman3/lists/python-ideas.python.org/
> Message archived at
> https://mail.python.org/archives/list/python-ideas@python.org/message/ZEKR2Y673GSHYBU5MBIHHLCSFF5YUALJ/
> Code of Conduct: http://python.org/psf/codeofconduct/
_______________________________________________
Python-ideas mailing list -- python-ideas@python.org
To unsubscribe send an email to python-ideas-le...@python.org
https://mail.python.org/mailman3/lists/python-ideas.python.org/
Message archived at
https://mail.python.org/archives/list/python-ideas@python.org/message/OSGNNVTHVU4BSMC65CGBFZ75PQETKPTA/
Code of Conduct: http://python.org/psf/codeofconduct/