enumerate overflow
Hrvoje Niksic
hniksic at xemacs.org
Wed Oct 3 15:08:41 EDT 2007
Raymond Hettinger <python at rcn.com> writes:
> [Paul Rubin]
>> I hope in 3.0 there's a real fix, i.e. the count should promote to
>> long.
>
> In Py2.6, I will mostly likely put in an automatic promotion to long
> for both enumerate() and count(). It took a while to figure-out how
> to do this without killing the performance for normal cases (ones
> used in real programs, not examples contrived to say, "omg, see what
> *could* happen").
Using PY_LONG_LONG for the counter, and PyLong_FromLongLong to create
the Python number should work well for huge sequences without
(visibly) slowing down the normal case.
More information about the Python-list
mailing list