id( ) function question
andreengels at gmail.com
Wed Oct 14 13:18:16 CEST 2009
What is going on is that a few objects that are often used, in
particular the small (how small is small depends on the
implementation) integers, are 'preloaded'. When one of these is then
referred to, a new object is not created, but the pre-defined object
is used. 10 is apparently a preloaded constant in your implementation,
1e10 is not.
As far as I know, only None is _guaranteed_ to be such a preloaded
object, so one should not rely on it in implementations.
On Wed, Oct 14, 2009 at 12:46 PM, raffaele ponzini
<raffaele.ponzini at gmail.com> wrote:
> Dear all,
> I have a question concerning the output of the id() function.
> In particular since is should:
> Return the identity of an object. This is guaranteed to be unique among
> simultaneously existing objects. (Hint: it's the object's memory address.)
> i expect that for two differnt objects it returns two differnt adress in memory.
> Let's seee a correct case:
>>>> a is b
>>>> c is a
> And now a strange (for me) output:
>>>> d=10 #here i'm assingning a integer value to a fresh new variable d without any kind of link to the variable a
>>>> d is a
>>>> d is a
André Engels, andreengels at gmail.com
More information about the Python-list