[Python-3000] Need help completing ABC pep

Nick Coghlan ncoghlan at gmail.com
Sat Apr 21 17:21:02 CEST 2007


Guido van Rossum wrote:
> On 4/21/07, Nick Coghlan <ncoghlan at gmail.com> wrote:
>> We've tried to do this before - the point where we got stuck was the
>> fact that Jython needed a separate location to store the default hash
>> method (unlike CPython, Jython's id() and object.__hash__() do different
>> things), and we couldn't come up with a reasonable location for it.
> 
> I don't understand. Why does the default hash method need to be stored
> in a location? Why couldn't it be a method on PyObj or whatever their
> base object it? Or are you talking about a place to store the hash
> *value*? But why would that need to be stored?

I believe the point was that currently object.__hash__ combines with 
object.__eq__ to give identity based comparison by default. If 
object.__hash__ is removed, then an appropriate hash function for 
identity-based comparison needs to be available somewhere else in the 
standard library - it was pointed out (by Samuele?) that id() is too 
expensive in Jython to be used directly as such a hash function.

I think the thread then devolved into a bikeshed discussion about 
possible different names (object.default_hash, sys.id_hash, etc, etc, 
...), which is why nothing was ever actually done about it.

Cheers,
Nick.

P.S. This discussion happened quite some time ago, and I haven't trawled 
through the list archive to check I'm remembering the details correctly. 
But I'm pretty sure I have the gist correct.

-- 
Nick Coghlan   |   ncoghlan at gmail.com   |   Brisbane, Australia
---------------------------------------------------------------
             http://www.boredomandlaziness.org


More information about the Python-3000 mailing list