[Python-ideas] Float range class

Todd toddrjen at gmail.com
Thu Jan 8 19:05:53 CET 2015


On Thu, Jan 8, 2015 at 6:45 PM, Antoine Pitrou <solipsis at pitrou.net> wrote:

> On Thu, 8 Jan 2015 17:01:03 +0100
> Todd <toddrjen at gmail.com> wrote:
> > Currently, the range class is limited to integers.  However, in many
> > applications, especially science and mathematics, ranges of float values
> > are the norm.
> >
> > The current approaches for float ranges all have significant limitations.
> > numpy.arange pre-allocates the values and doesn't use python floats, both
> > of which affect performance.  List comprehensions also have to be
> > pre-allocated.  Generators and values created in the body of a loop
> cannot
> > be indexed or re-used and are much more verbose and harder to read.  So
> it
> > would be nice to have a float equivalent of the existing range class.
>
> What use do you have for a lazily allocated floating-point range?
>
> Regards
>
> Antoine.
>
>
The most common use-case is similar to the existing range: looping or
iterating over values needed for some computation.  This can become much
more complicated, however, in many numerical algorithms where the exact
order of the values you access cannot be known beforehand.  You can save a
huge amount of memory by not pre-allocating an array of such values, but
that requires making the range indexable.
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.python.org/pipermail/python-ideas/attachments/20150108/babc0d98/attachment.html>


More information about the Python-ideas mailing list