Travis E. Oliphant wrote:
> Here is my C-API proposal
> 
> 1) PyIndex_Check(obj)
> 
>    Similar to PyIter_Check(obj) as it just checks for whether or not the 
> object can call nb_index.  Actually implemented as a macro.
> 
> 2) PyObject* PyNumber_Index(obj)
> 
>    Simple interface around nb_index 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) Py_ssize_t PyNumber_AsSsize_t(obj, err)
> 
>     This converts the object to a Py_ssize_t by using the nb_index 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
>     Py_ssize_t 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 
> PyExc_IndexError and PyExc_OverflowError will be the errors used.
> 

This proposal is implemented as patch 1538606 
http://sourceforge.net/tracker/index.php?func=detail&aid=1538606&group_id=5470&atid=305470


-Travis

_______________________________________________
Python-Dev mailing list
Python-Dev@python.org
http://mail.python.org/mailman/listinfo/python-dev
Unsubscribe: 
http://mail.python.org/mailman/options/python-dev/archive%40mail-archive.com

Reply via email to