On 2/13/06, Jim Jewett <jimjjewett at gmail.com> 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/)
RetroSearch is an open source project built by @garambo | Open a GitHub Issue
Search and Browse the WWW like it's 1997 | Search results from DuckDuckGo
HTML:
3.2
| Encoding:
UTF-8
| Version:
0.7.4