[Python-Dev] index clipping (original) (raw)
Travis E. Oliphant oliphant.travis at ieee.org
Fri Aug 11 12:53:48 CEST 2006
- Previous message: [Python-Dev] __index__ clipping
- Next message: [Python-Dev] __index__ clipping
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]
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&group_id=5470&atid=305470
-Travis
- Previous message: [Python-Dev] __index__ clipping
- Next message: [Python-Dev] __index__ clipping
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]