This issue tracker has been migrated to GitHub, and is currently read-only.
For more information, see the GitHub FAQs in the Python's Developer Guide.

Author rhettinger
Recipients christian.heimes, georg.brandl, ldeller, rhettinger, tim.peters, vstinner
Date 2008-10-03.17:02:18
SpamBayes Score 1.110223e-16
Marked as misclassified No
Message-id <1223053340.28.0.7835134238.issue4024@psf.upfronthosting.co.za>
In-reply-to
Content
I question whether this should be done at all.  Making the creation of a
float even slightly slower is bad.  This is on the critical path for all
floating point intensive computations.  If someone really cares about
the memory savings, it is not hard take a single in instance of float
and use it everywhere:  ZERO=0.0; arr=[ZERO if x == 0.0 else x for x in
arr].  That technique also works for 1.0 and -1.0 and pi and other
values that may commonly occur in a particular app.  Also, the technique
is portable to implementations other than CPython.  I don't mind this
sort of optimization for immutable containers but feel that floats are
too granular.  Special cases aren't special enough to break the rules. 
If the OP is insistent, then at least this should be discussed with the
numeric community who will have a better insight into whether the
speed/space trade-off makes sense in other applications beyond the OP's
original case.

Tim, any insights?
History
Date User Action Args
2008-10-03 17:02:20rhettingersetrecipients: + rhettinger, tim.peters, georg.brandl, vstinner, ldeller, christian.heimes
2008-10-03 17:02:20rhettingersetmessageid: <1223053340.28.0.7835134238.issue4024@psf.upfronthosting.co.za>
2008-10-03 17:02:19rhettingerlinkissue4024 messages
2008-10-03 17:02:18rhettingercreate