[Python-3000] hash as attribute/property
Delaney, Timothy (Tim)
tdelaney at avaya.com
Wed Apr 5 00:24:05 CEST 2006
Guido van Rossum wrote:
> The __hash__() method qualifies, which is why it's a tough call (I'll
> come back on that; I want to come up with a reason why __hash__()
> should remain a method). The iterator-getting example above doesn't
> qualify.
Yeah - I felt it was a borderline case, so thought it was a good case
for setting a precedent.
Pros for making it an attribute/property:
1. It should return the same value each time.
2. Faster access for many types.
Cons:
1. Gratuitous breakage with 2.x.
2. If it's a property, subclasses need to override the getter and
recreate the property if they want to change the hash of the object
(unless the base class uses a lazy property).
Tim Delaney
More information about the Python-3000
mailing list