[Python-Dev] index clipping (original) (raw)

Guido van Rossum guido at python.org
Fri Aug 11 16:57:46 CEST 2006


OK, I'll withdraw from this discussion again. Thanks all!

On 8/11/06, Nick Coghlan <ncoghlan at gmail.com> wrote:

Travis E. Oliphant wrote: > Travis E. Oliphant wrote: >> Here is my C-API proposal >> >> 1) PyIndexCheck(obj) >> >> Similar to PyIterCheck(obj) as it just checks for whether or not the >> object can call nbindex. Actually implemented as a macro. >> >> 2) PyObject* PyNumberIndex(obj) >> >> Simple interface around nbindex that calls it if possible and returns >> TypeError if not (or if the result does not end up in an exact >> int-or-long >> >> 3) Pyssizet PyNumberAsSsizet(obj, err) >> >> This converts the object to a Pyssizet by using the nbindex call >> if possible. The err argument is a Python error object and specifies >> what error should be raised should the conversion from Int-or-Long to >> Pyssizet cause Overflow. >> >> If err is NULL, then no error will be raised and the result will be >> clipped. Other-wise the corresponding error will be set. Internally >> PyExcIndexError and PyExcOverflowError will be the errors used. >> > > This proposal is implemented as patch 1538606 > http://sourceforge.net/tracker/index.php?func=detail&aid=1538606&groupid=5470&atid=305470

This interface is a lot simpler to explain and use than the one in my patch, and more in tune with the rest of the C API. I had a minor documentation suggestion which I put on the tracker item, but other than that +1 on using Travis's patch instead of mine (I've already rejected my own tracker item). Cheers, Nick. -- Nick Coghlan | ncoghlan at gmail.com | Brisbane, Australia --------------------------------------------------------------- http://www.boredomandlaziness.org


Python-Dev mailing list Python-Dev at python.org http://mail.python.org/mailman/listinfo/python-dev Unsubscribe: http://mail.python.org/mailman/options/python-dev/guido%40python.org

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



More information about the Python-Dev mailing list