On 2/13/06, Jim Jewett <[EMAIL PROTECTED]> wrote:
> Travis wrote:
>
> > The patch adds a new API function int PyObject_AsIndex(obj)
>
> How did you decide between int and long?
>
> Why not ssize_t?
It should be the same type used everywhere for indexing. In the svn
HEAD that's int. Once PEP 353 lands it should be ssize_t. I've made
Travis aware of this issue already.
> Also, if index is being added as a builtin, should the failure
> result be changed?
I don't like to add a built-in index() at this point; mostly because
of Occam's razor (we haven't found a need).
> I'm thinking that this may become a
> replacement for isinstance(val, (int, long)).
But only if it's okay if values > sys.maxint (or some other constant
indicating the limit of ssize_t) are not required to be supported.
> If so, it might
> be nice not to raise errors, or at least to raise a more
> specific subclass. (Catching a TypeError and then
> checking the message string ... does not seem clean.)
I'm not sure what you mean. How could index(x) ever replace
isinstance(x, (int, long)) without raising an exception? Surely
index("abc") *should* raise an exception.
--
--Guido van Rossum (home page: http://www.python.org/~guido/)
_______________________________________________
Python-Dev mailing list
[email protected]
http://mail.python.org/mailman/listinfo/python-dev
Unsubscribe:
http://mail.python.org/mailman/options/python-dev/archive%40mail-archive.com