[Python-Dev] getting rid of default object.hash (SF 660098) (original) (raw)
Samuele Pedroni pedronis at bluewin.ch
Mon Dec 22 16:43:40 EST 2003
- Previous message: [Python-Dev] getting rid of default object.__hash__ (SF 660098)
- Next message: [Python-Dev] getting rid of default object.__hash__ (SF 660098)
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]
At 13:32 22.12.2003 -0800, Guido van Rossum wrote:
> >Since the default hash simply takes id() of the object, it's easy to > >fix such code once the failure is understood though. > > Jython 2.2a0 on java1.4.002 (JIT: null) > Type "copyright", "credits" or "license" for more information. > >>> class C: pass > ... > >>> id(C) > 1 > >>> hash(C) > 9174506 > >>> > > I see, but then there should be probably be a different way to spell > the default hash, because id is not a sensible option for Jython etc
Ow, you're right. I bet this is why object.hash was introduced in the first place. We're either back to square one, or we can add a defaulthash to object which has the default hash implementation -- this isn't very pretty but at least it works.
yes, or hash should grow a keyword argument to get access to the default impl, which would be id for CPython but not for all Python impls in general. The problem is that in general it cannot be expected from Python implementations to implement the default hash in terms of id because the latter can be much more costly beacuse of its uniqueness constraints.
regards.
- Previous message: [Python-Dev] getting rid of default object.__hash__ (SF 660098)
- Next message: [Python-Dev] getting rid of default object.__hash__ (SF 660098)
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]