<div dir="ltr"><div><div><div><div><div><p dir="ltr">Currently, the range class is limited to integers.  However, in many applications, especially science and mathematics, ranges of float values are the norm.  </p>
<p dir="ltr">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.<br></p><p dir="ltr"></p>Assuming such a class is worthwhile, I see three possible ways to handle float ranges, each with its own strengths and weaknesses.  I am not sure which, if any, is preferable.<br><br></div>The first is to extend the existing range class so it can support floats or to 
use duck-typing to support any class that has the necessary methods. However, I would be worried about making such a fundamental change to such a core class, and either approach could hurt performance.<br></div><br></div>The second approach is to create a new class that handles floating-point ranges (perhaps called "frange") and/or a new class that handles duck-typed ranges (perhaps called "drange").  However, there isn't really a good place right now to put these as far as I can see.<br><br></div>The third approach is to create a new module for various range classes.  For example there could be a float range, a datetime range, a decimal range, a duck-typed range, an abstract base class for making new range classes, etc.  However, this is a lot more work (although it wouldn't need to all be done at one time).<br></div><br></div>