[Python-Dev] Caching float(0.0)

"Martin v. Löwis" martin at v.loewis.de
Tue Oct 3 14:30:35 CEST 2006


Nick Maclaren schrieb:
>> The total count of floating point numbers allocated at this point is 985794.
>> Without the reuse, they would be 1317145, so this is a saving of 25%, and
>> of 5Mb.
> 
> And, if you optimised just 0.0, you would get 60% of that saving at
> a small fraction of the cost and considerably greater generality.

As Michael Hudson observed, this is difficult to implement, though:
You can't distinguish between -0.0 and +0.0 easily, yet you should.

Regards,
Martin


More information about the Python-Dev mailing list