[Python-Dev] gc ideas -- sparse memory

Stephen J. Turnbull stephen at xemacs.org
Sun Dec 5 09:17:37 CET 2010

"Martin v. Löwis" writes:
 > > Why is useful to expose an identity hash?  AFAICS it is *only* useful
 > > in building an identity hash table.  If so, why not just provide id()
 > > or the is operator or both and be done with it?
 > That's precisely James' point: Java provides the identity hash
 > *instead* of the id() function (i.e. it does not have an equivalent
 > of id()). Doing so gives greater liberties in implementing Java.

Yes, we understand that it makes the implementer's job easier.  *Why
bother having an identity hash at all?*  Having taken away id() and
provided maximum leisure to the implementer via

def identity_hash(object):
    return 42

is there *any* benefit left for the user/developer?  All I see is
costs: costs in implementation, costs in debugging.  And AFAICS this
is a problem that can be solved once and reused by everybody who needs
id(); why does every developer need to write his own id() function?

More information about the Python-Dev mailing list