[Python-Dev] Caching float(0.0)
Tim Hochberg
tim.hochberg at ieee.org
Mon Oct 2 19:43:51 CEST 2006
skip at pobox.com wrote:\/
> Steve> By these statistics I think the answer to the original question
> Steve> is clearly "no" in the general case.
>
> As someone else (Guido?) pointed out, the literal case isn't all that
> interesting. I modified floatobject.c to track a few interesting
> floating point values:
>
[...code...]
>
> So for a largely non-floating point "application", a fair number of floats
> are allocated, a bit over 25% of them are -1.0, 0.0 or +1.0, and nearly 50%
> of them are whole numbers between -10.0 and 10.0, inclusive.
>
> Seems like it at least deserves a serious look. It would be nice to have
> the numeric crowd contribute to this subject as well.
As a representative of the numeric crowd, I'll say that I've never
noticed this to be a problem. I suspect that it's a non issue since we
generally store our numbers in arrays, not big piles of Python floats,
so there's no opportunity for identical floats to pile up.
-tim
More information about the Python-Dev
mailing list