[Python-Dev] Fixing _PyEval_SliceIndex so that integer-like objects can be used

Guido van Rossum gvanrossum at gmail.com
Fri Feb 18 22:28:34 CET 2005

> Would it be possible to change
> _PyEval_SliceIndex  in ceval.c
> so that rather than throwing an error if the indexing object is not an
> integer, the code first checks to see if the object has a
> tp_as_number->nb_int method and calls it instead.

I don't think this is the right solution; since float has that method,
it would allow floats to be used as slice indices, but that's not
supposed to work (to protect yourself against irreproducible results
due to rounding errors).

--Guido van Rossum (home page: http://www.python.org/~guido/)

More information about the Python-Dev mailing list