[Python-3000] range() issues
Benjamin Peterson
musiccomposition at gmail.com
Sat Apr 26 20:58:20 CEST 2008
On Sat, Apr 26, 2008 at 1:49 PM, Facundo Batista
<facundobatista at gmail.com> wrote:
> Which should the range() definition be, in your words?
"A set of integers from start to stop skipping step."
[ ... ]
> At this moment I stopped writing this mail, and I went to code a
> Range() class to have the semantics that we're seeking here (it's
> attached), and I couldn't finish it 100% because of a len() behaviour
> that I'm including here, because it's related to what we're discussing
> here:
>
> >>> class C:
> ... def __len__(self):
> ... return 100000000000000000000000000000
> ...
> >>> c = C()
> >>> len(c)
> Traceback (most recent call last):
> File "<stdin>", line 1, in <module>
> OverflowError: Python int too large to convert to C ssize_t
>
> >From an external point of view, and knowing that ints are unbound, why
> should I have an error here?
lens are forced to be <= Py_ssize_t because that's the limit put on
sequence sizes.
--
Cheers,
Benjamin Peterson
More information about the Python-3000
mailing list