[Python-Dev] print "%X" % id(object()) not so nice
James Y Knight
foom at fuhm.net
Fri Nov 19 21:48:19 CET 2004
I think id() should never be returning a negative number. Both these
behaviors are poor:
In 2.3:
>>> print "%X" % id(o)
__main__:1: FutureWarning: %u/%o/%x/%X of negative int will return a
signed string in Python 2.4 and up
A5F48198
In 2.4:
>>> print "%X" %id(o)
-5FC84D08
Pointers are conventionally never treated or printed as signed. In 2.3
and before, it usually ended up okay, besides the warning, because "%X"
had broken behavior. In 2.4, now it's ending up doing the wrong thing
and printing a confusing value. I propose that id() always return a
positive value. This means that it will sometimes have to return a long
instead of an int, but, it already does that under some circumstances
on some architectures.
Comments?
James
More information about the Python-Dev
mailing list