[Python-Dev] Caching float(0.0)
tjreedy at udel.edu
Sun Oct 1 19:54:31 CEST 2006
"Nick Craig-Wood" <nick at craig-wood.com> wrote in message
news:20061001093846.GA20938 at craig-wood.com...
> On Fri, Sep 29, 2006 at 12:03:03PM -0700, Guido van Rossum wrote:
>> I see some confusion in this thread.
>> If a *LITERAL* 0.0 (or any other float literal) is used, you only get
>> one object, no matter how many times it is used.
> For some reason that doesn't happen in the interpreter which has been
> confusing the issue slightly...
> $ python2.5
>>>> id(a), id(b)
> (134737756, 134737772)
Guido said *a* literal (emphasis shifted), reused as in a loop or function
recalled, while you used *a* literal, then *another* literal, without
reuse. Try a=b=0.0 instead.
Terry Jan Reedy
More information about the Python-Dev