[Python-Dev] Caching float(0.0)

Nick Coghlan ncoghlan at gmail.com
Sat Sep 30 10:59:25 CEST 2006


Martin v. Löwis wrote:
> Bob Ippolito schrieb:
>> My guess is that people do have this problem, they just don't know
>> where that memory has gone. I know I don't count objects unless I have
>> a process that's leaking memory or it grows so big that I notice (by
>> swapping or chance).
> 
> Right. Although I do wonder what kind of software people write to run
> into this problem. As Guido points out, the numbers must be the result
> from some computation, or created by an extension module by different
> means. If people have many *simultaneous* copies of 0.0, I would expect
> there is something else really wrong with the data structures or
> algorithms they use.

I suspect the problem would typically stem from floating point values that are 
read in from a human-readable file rather than being the result of a 
'calculation' as such:

 >>> float('1') is float('1')
False
 >>> float('0') is float('0')
False

Cheers,
Nick.

-- 
Nick Coghlan   |   ncoghlan at gmail.com   |   Brisbane, Australia
---------------------------------------------------------------
             http://www.boredomandlaziness.org


More information about the Python-Dev mailing list