Well, a lot of extension code, like ours use PyFloat_FromDouble(foo);  This can 
be from vectors and stuff.  Very often these are values from a database.  
Integral float values are very common in such case and id didn't occur to me 
that they weren't being reused, at least for small values.

Also, a lot of arithmetic involving floats is expected to end in integers, like 
computing some index from a float value.  Integers get promoted to floats when 
touched by them, as you know.

Anyway, I now precreate integral values from -10 to 10 with great effect.  The 
cost is minimal, the benefit great.

Cheers,
Kristján

-----Original Message-----
From: [EMAIL PROTECTED] [mailto:[EMAIL PROTECTED] On Behalf Of "Martin v. Löwis"
Sent: 30. september 2006 08:48
To: Bob Ippolito
Cc: python-dev@python.org
Subject: Re: [Python-Dev] Caching float(0.0)

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.

Regards,
Martin
_______________________________________________
Python-Dev mailing list
Python-Dev@python.org
http://mail.python.org/mailman/listinfo/python-dev
Unsubscribe: 
http://mail.python.org/mailman/options/python-dev/kristjan%40ccpgames.com
_______________________________________________
Python-Dev mailing list
Python-Dev@python.org
http://mail.python.org/mailman/listinfo/python-dev
Unsubscribe: 
http://mail.python.org/mailman/options/python-dev/archive%40mail-archive.com

Reply via email to