On 16Mar2022 14:00, Marco Sulla <marco.sulla.pyt...@gmail.com> wrote: >On Wed, 16 Mar 2022 at 00:42, Cameron Simpson <c...@cskk.id.au> wrote: >> >In this case I currently cache the value -1. The subsequent calls to >> >__hash__() will check if the value is -1. If so, a TypeError is >> >immediately raised. >> >> This will also make these values behave badly in dicts/sets, as they all >> hash to the same bucket. > >Not sure to understand. If the hash is -1, it's not hashable, so it >can't be a member of a dict or set.
Sorry, I misread you and took -1 to be a valid hash code, not a signal to raise TypeError. Cheers, Cameron Simpson <c...@cskk.id.au> -- https://mail.python.org/mailman/listinfo/python-list