[Python-ideas] Float range class

Andrew Barnert abarnert at yahoo.com
Sat Jan 10 10:09:22 CET 2015


On Jan 9, 2015, at 23:03, Andrew Barnert <abarnert at yahoo.com.dmarc.invalid> wrote:

> On Jan 9, 2015, at 21:13, Guido van Rossum <guido at python.org> wrote:
> 
>> On Fri, Jan 9, 2015 at 7:29 PM, Andrew Barnert <abarnert at yahoo.com.dmarc.invalid> wrote:
>>> On Jan 9, 2015, at 14:36, Guido van Rossum <guido at python.org> wrote:

>> - make it a lazy sequence, with slicing ability, etc.
> 
> If you don't need O(1) __contains__ and friends (and I don't think you do) that's maybe 5 lines of code with the ABC.

Actually, one problem here: computing the linspace corresponding to a slice of another linspace is not guaranteed to give you the same values. For example, using the second algorithm, lisf(linspace(0, 1, 11)[::3]) != list(linspace(0, .9, 4)). Using the first algorithm, list(linspace(-2, 2, 20))[1::2] != list(linspace(-1.7894736842105263, 2, 10).

So, does this mean a slice of a linspace should be a list? A linspace whose values may not compare equal? A special linspace-slice-view object?

-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.python.org/pipermail/python-ideas/attachments/20150110/7458c148/attachment-0001.html>


More information about the Python-ideas mailing list