[Python-Dev] For Python 3k, drop default/implicit hash, and comparison

Adam Olsen rhamph at gmail.com
Sun Nov 27 01:25:15 CET 2005


On 11/26/05, Noam Raphael <noamraph at gmail.com> wrote:
> [...stuff about using Ref() for identity dictionaries...]

I too have thought along these lines, but I went one step further. 
There is an existing function that could be modified to produce Ref
objects: id().

Making id() into a type allows it force unsignedness, incorporate a
method for easy printing, maintain a reference to the target so that
"id(x.foo) == id(x.bar)" doesn't risk reusing the same id.. and the id
object would be the same size as an int object is today.  I don't see
any disadvantage, except perhaps code that assumes id() returns an
int.  That could be fixed by having id() subclass int for a few
versions while we transition, although that may require we store the
pointer seperate from the integer value.

id() would be usable in dicts as a value, behaving as Noam suggests
that Ref behave.  Kills two birds with one stone.

--
Adam Olsen, aka Rhamphoryncus


More information about the Python-Dev mailing list