![](https://secure.gravatar.com/avatar/300c354313a8c8628291c44c594f9b01.jpg?s=120&d=mm&r=g)
On 07/13/2011 11:37 AM Bengt Richter wrote: <snip>...</snip>
Hm. I downloaded pypy and it does optimize constant storage for 1003 is 1000+3
<snip>...</snip>
Of course, the id's are all still id's of garbage locations once returned from id ;-)
So how about returning None instead of id's of garbage, or raising an exception? Would that not be pythonic?
Hm, other than practicality beating purity ;-/ Sorry to be commenting on myself, but a further thought: In a way, a constant could be considered a specially-named immutable variable, e.g., "1003" "names" 1003, so one could consider the id of an arbitrary constant (even if perhaps only "named" and its value referenced in bytecode due to constant folding from source expressions) to be the id of a live object. But I still think there will be examples of id arguments that will turn to garbage as soon as id returns -- and renders the id erroneous for any use besides a debugging peek at memory usage. I.e., there will be temp objects with no persistence beyond the scope of the argument use within id, other than while ahead in a race with garbage collection. Is there an easy way to check on whether the argument *only* has the one reference from id's arg list? When is a ref count not available? Do simple atomic constants have them? E.g., small integers vs bigger? And True, False, None? ()? and []? Regards, Bengt Richter