[Python-ideas] Introduce collections.Reiterable
Oscar Benjamin
oscar.j.benjamin at gmail.com
Mon Sep 23 10:55:19 CEST 2013
On 23 September 2013 09:44, Nick Coghlan <ncoghlan at gmail.com> wrote:
>
> The fact Python 3 lets you create ranges you can't directly take the
> length of is a bit of a hack, too (because of the pain involved in
> defining an alternative __len__ protocol that didn't funnel everything
> through an ssize_t value):
>
>>>> x = range(10**100)
>>>> len(x)
> Traceback (most recent call last):
> File "<stdin>", line 1, in <module>
> OverflowError: Python int too large to convert to C ssize_t
>>>> (x.stop - x.start) // x.step
> 10000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000
I wouldn't call that a "hack". It's clearly a bug.
Oscar
More information about the Python-ideas
mailing list