[Python-Dev] sizeof(long) != sizeof(void*)
Samuele Pedroni
pedronis at bluewin.ch
Wed Aug 6 22:24:15 EDT 2003
At 14:48 06.08.2003 -0400, Tim Peters wrote:
>[Guido]
> > OK, but in the past (when I was younger :-) *I* thought
> > that that was a safe claim, otherwise I wouldn't have implemented
> > id() the way it was. In that past, the difference between Python int
> > and long was much greater, since much of the C library code wouldn't
> > deal with longs at all.
>
>Well, that's all in the past, and id() isn't implemented that way anymore;
>at this time it's just a fact that a Python int isn't big enough to hold a
>machine address on all boxes.
but that something like id() can be cheaply offered/exposed is very much a
characteristic of the underlying GC implementation that is being exploited
(objects don't move), and the GC impl is an overall implementation detail.
I have just gone through implementing a correct id() for Jython.
For the serious usage id() would be better substituted by an identity
mapping implementation which initially for CPython could simply be using
id(). But the user would use that and not rely on id().
id() could maybe be kept around for debugging purposes.
Now, a next step anyway for Jython is to modify copy.py (.deepcopy) to use
an indenty mapping instead of id(), either having a Jython version or
changing CPython one with approriate conditional logic.
regards.
More information about the Python-Dev
mailing list