Why __hash__() does not return an UUID4?

2QdxY4RzWzUUiLuE at potatochowder.com 2QdxY4RzWzUUiLuE at potatochowder.com
Wed Aug 26 17:13:50 EDT 2020


On 2020-08-26 at 22:10:26 +0200,
Marco Sulla <Marco.Sulla.Python at gmail.com> wrote:

> As title ...

Assuming that the title appears prominently with the content of your
email.  For the rest of us:

    Why __hash__() does not return an UUID4?

> ... The reasons that came in my mind are:
> 
> 1. speed
> 2. security

Correctness?

Why would __hash__() return a random number?  An important property of
hashes is that if x == y, then hash(x) == hash(y).  If hash(x) and
hash(y) were random numbers, then how would this property be maintained?

Or do UUID4 mean something else to you than a random number?


More information about the Python-list mailing list