[Python-Dev] Caching float(0.0)

Guido van Rossum guido at python.org
Fri Sep 29 21:03:03 CEST 2006

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.

But if the result of a *COMPUTATION* returns 0.0, you get a new object
for each such result. If you have 70 MB worth of zeros, that's clearly
computation results, not literals.

Attempts to remove literal references from source code won't help much.

I'm personally +0 on caching computational results with common float
values such as 0 and small (positive or negative) powers of two, e.g.
0.5, 1.0, 2.0.

--Guido van Rossum (home page: http://www.python.org/~guido/)

More information about the Python-Dev mailing list