[issue4024] float(0.0) singleton
lplatypus
report at bugs.python.org
Fri Oct 3 05:25:07 CEST 2008
New submission from lplatypus <luke at deller.id.au>:
Here is a patch to make PyFloat_FromDouble(0.0) always return the same
float instance. This is similar to the existing optimization in
PyInt_FromLong(x) for small x.
My own motivation is that the patch reduces memory by several megabytes
for a particular in-house data processing script, but I think that it
should be generally useful assuming that zero is a very common float
value, and at worst almost neutral when this assumption is wrong. The
minimal performance impact of the test for zero should be easily
recovered by reduced memory allocation calls. I am happy to look into
benchmarking if you require empirical performance data.
----------
components: Interpreter Core
files: python_zero_float.patch
keywords: patch
messages: 74224
nosy: ldeller
severity: normal
status: open
title: float(0.0) singleton
type: resource usage
versions: Python 2.6
Added file: http://bugs.python.org/file11686/python_zero_float.patch
_______________________________________
Python tracker <report at bugs.python.org>
<http://bugs.python.org/issue4024>
_______________________________________
More information about the Python-bugs-list
mailing list