Python/C API .pxi from Eric Huss
authorRobert Bradshaw <robertwb@math.washington.edu>
Sun, 30 Mar 2008 10:15:58 +0000 (03:15 -0700)
committerRobert Bradshaw <robertwb@math.washington.edu>
Sun, 30 Mar 2008 10:15:58 +0000 (03:15 -0700)
Includes/python2.5.pxi [new file with mode: 0644]

diff --git a/Includes/python2.5.pxi b/Includes/python2.5.pxi
new file mode 100644 (file)
index 0000000..502601f
--- /dev/null
@@ -0,0 +1,627 @@
+# From: Eric Huss <e-huss@netmeridian.com>\r
+#\r
+# Here is my latest copy.  It does not cover 100% of the API.  It should be\r
+# current up to 2.5.\r
+#\r
+# -Eric\r
+\r
+\r
+\r
+\r
+# XXX:\r
+# - Need to support "long long" definitions that are different for different platforms.\r
+# - Support unicode platform dependencies.\r
+# - Add unicode calls.\r
+# - Add setobject calls.\r
+\r
+cdef extern from "sys/types.h":\r
+    ctypedef unsigned int size_t\r
+    ctypedef int          ssize_t\r
+\r
+cdef extern from "stdio.h":\r
+    ctypedef struct FILE:\r
+        pass\r
+\r
+cdef extern from "Python.h":\r
+\r
+    # XXX: This is platform dependent.\r
+    ctypedef unsigned short Py_UNICODE\r
+    ctypedef ssize_t        Py_ssize_t\r
+\r
+    ctypedef struct PyTypeObject:\r
+        pass\r
+\r
+    ctypedef struct PyObject:\r
+        Py_ssize_t ob_refcnt\r
+        PyTypeObject * ob_type\r
+\r
+    ###############################################################################################\r
+    # bool\r
+    ###############################################################################################\r
+    PyObject * Py_False\r
+    PyObject * Py_True\r
+    PyTypeObject PyBool_Type\r
+    int                 PyBool_Check                    (object)                    # Always succeeds.\r
+    object              PyBool_FromLong                 (long)\r
+\r
+    ###############################################################################################\r
+    # buffer\r
+    ###############################################################################################\r
+    PyTypeObject PyBuffer_Type\r
+    int Py_END_OF_BUFFER\r
+    int                 PyBuffer_Check                  (object)                    # Always succeeds.\r
+    object              PyBuffer_FromMemory             (void *, Py_ssize_t)\r
+    object              PyBuffer_FromObject             (object, Py_ssize_t, Py_ssize_t)\r
+    object              PyBuffer_FromReadWriteMemory    (void *, Py_ssize_t)\r
+    object              PyBuffer_FromReadWriteObject    (object, Py_ssize_t, Py_ssize_t)\r
+    object              PyBuffer_New                    (Py_ssize_t)\r
+    int                 PyObject_AsCharBuffer           (object, char **, Py_ssize_t *)    except -1\r
+    int                 PyObject_AsReadBuffer           (object, void **, Py_ssize_t *)    except -1\r
+    int                 PyObject_AsWriteBuffer          (object, void **, Py_ssize_t *)    except -1\r
+    int                 PyObject_CheckReadBuffer        (object)                    # Always succeeds.\r
+\r
+    ###############################################################################################\r
+    # cobject\r
+    ###############################################################################################\r
+    PyTypeObject PyCObject_Type\r
+\r
+    int                 PyCObject_Check(object)                                     # Always succeeds.\r
+    object              PyCObject_FromVoidPtr(void *, void (*)(void*))\r
+    object              PyCObject_FromVoidPtrAndDesc(void *, void *, void (*)(void*,void*))\r
+    void *              PyCObject_AsVoidPtr(object)                                 except NULL\r
+    void *              PyCObject_GetDesc(object)                                   except NULL\r
+    void *              PyCObject_Import(char *, char *)                            except NULL\r
+\r
+    ###############################################################################################\r
+    # compile\r
+    ###############################################################################################\r
+\r
+    ctypedef struct PyCodeObject:\r
+        int       co_argcount\r
+        int       co_nlocals\r
+        int       co_stacksize\r
+        int       co_flags\r
+        PyObject *co_code\r
+        PyObject *co_consts\r
+        PyObject *co_names\r
+        PyObject *co_varnames\r
+        PyObject *co_freevars\r
+        PyObject *co_cellvars\r
+        PyObject *co_filename\r
+        PyObject *co_name\r
+        int       co_firstlineno\r
+        PyObject *co_lnotab\r
+\r
+    int PyCode_Addr2Line(PyCodeObject *, int)\r
+\r
+    ###############################################################################################\r
+    # complex\r
+    ###############################################################################################\r
+    ctypedef struct Py_complex:\r
+        double real\r
+        double imag\r
+\r
+    PyTypeObject PyComplex_Type\r
+\r
+    Py_complex          PyComplex_AsCComplex            (object)                    # Always succeeds.\r
+    int                 PyComplex_Check                 (object)                    # Always succeeds.\r
+    int                 PyComplex_CheckExact            (object)                    # Always succeeds.\r
+    object              PyComplex_FromCComplex          (Py_complex)\r
+    object              PyComplex_FromDoubles           (double, double)\r
+    double              PyComplex_ImagAsDouble          (object)                    except? -1\r
+    double              PyComplex_RealAsDouble          (object)                    except? -1\r
+    Py_complex          _Py_c_diff                      (Py_complex, Py_complex)\r
+    Py_complex          _Py_c_neg                       (Py_complex)\r
+    Py_complex          _Py_c_pow                       (Py_complex, Py_complex)\r
+    Py_complex          _Py_c_prod                      (Py_complex, Py_complex)\r
+    Py_complex          _Py_c_quot                      (Py_complex, Py_complex)\r
+    Py_complex          _Py_c_sum                       (Py_complex, Py_complex)\r
+\r
+    ###############################################################################################\r
+    # dict\r
+    ###############################################################################################\r
+    PyTypeObject PyDict_Type\r
+\r
+    int                 PyDict_Check                    (object)                    # Always succeeds.\r
+    int                 PyDict_CheckExact               (object)                    # Always succeeds.\r
+    void                PyDict_Clear                    (object)\r
+    int                 PyDict_Contains                 (object, object)            except -1\r
+    object              PyDict_Copy                     (object)\r
+    int                 PyDict_DelItem                  (object, object)            except -1\r
+    int                 PyDict_DelItemString            (object, char *)            except -1\r
+    object              PyDict_Items                    (object)\r
+    object              PyDict_Keys                     (object)\r
+    int                 PyDict_Merge                    (object, object, int)       except -1\r
+    int                 PyDict_MergeFromSeq2            (object, object, int)       except -1\r
+    object              PyDict_New                      ()\r
+    # XXX: Pyrex doesn't support pointer to a python object?\r
+    #int                 PyDict_Next                     (object, Py_ssize_t *, object *, object *) # Always succeeds.\r
+    int                 PyDict_SetItem                  (object, object, object)    except -1\r
+    int                 PyDict_SetItemString            (object, char *, object)    except -1\r
+    Py_ssize_t          PyDict_Size                     (object)                    except -1\r
+    int                 PyDict_Update                   (object, object)            except -1\r
+    object              PyDict_Values                   (object)\r
+    # XXX: Borrowed reference.  No exception on NULL.\r
+    #object              PyDict_GetItem                  (object, object)\r
+    # XXX: Borrowed reference.  No exception on NULL\r
+    #object              PyDict_GetItemString            (object, char *)\r
+\r
+\r
+    ###############################################################################################\r
+    # float\r
+    ###############################################################################################\r
+    PyTypeObject PyFloat_Type\r
+    int                 _PyFloat_Pack4                  (double, unsigned char *, int)  except -1\r
+    int                 _PyFloat_Pack8                  (double, unsigned char *, int)  except -1\r
+    double              _PyFloat_Unpack4                (unsigned char *, int)      except? -1\r
+    double              _PyFloat_Unpack8                (unsigned char *, int)      except? -1\r
+    double              PyFloat_AS_DOUBLE               (object)\r
+    double              PyFloat_AsDouble                (object)                    except? -1\r
+    void                PyFloat_AsReprString            (char*, object)\r
+    void                PyFloat_AsString                (char*, object)\r
+    int                 PyFloat_Check                   (object)                    # Always succeeds.\r
+    int                 PyFloat_CheckExact              (object)                    # Always succeeds.\r
+    object              PyFloat_FromDouble              (double)\r
+    object              PyFloat_FromString              (object, char**)\r
+\r
+    ###############################################################################################\r
+    # frame\r
+    ###############################################################################################\r
+\r
+    ctypedef struct PyFrameObject:\r
+        PyFrameObject *f_back\r
+        PyCodeObject  *f_code\r
+        PyObject *f_builtins\r
+        PyObject *f_globals\r
+        PyObject *f_locals\r
+        PyObject *f_trace\r
+        PyObject *f_exc_type\r
+        PyObject *f_exc_value\r
+        PyObject *f_exc_traceback\r
+        int f_lasti\r
+        int f_lineno\r
+        int f_restricted\r
+        int f_iblock\r
+        int f_nlocals\r
+        int f_ncells\r
+        int f_nfreevars\r
+        int f_stacksize\r
+\r
+    ###############################################################################################\r
+    # int\r
+    ###############################################################################################\r
+    PyTypeObject PyInt_Type\r
+    long                PyInt_AS_LONG                   (object)                    # Always succeeds.\r
+    long                PyInt_AsLong                    (object)                    except? -1\r
+    Py_ssize_t          PyInt_AsSsize_t                 (object)                    except? -1\r
+    unsigned long long  PyInt_AsUnsignedLongLongMask    (object)                    except? -1\r
+    unsigned long       PyInt_AsUnsignedLongMask        (object)                    except? -1\r
+    int                 PyInt_Check                     (object)                    # Always succeeds.\r
+    int                 PyInt_CheckExact                (object)                    # Always succeeds.\r
+    object              PyInt_FromLong                  (long)\r
+    object              PyInt_FromSsize_t               (Py_ssize_t)\r
+    object              PyInt_FromString                (char*, char**, int)\r
+    object              PyInt_FromUnicode               (Py_UNICODE*, Py_ssize_t, int)\r
+    long                PyInt_GetMax                    ()                      # Always succeeds.\r
+\r
+    ###############################################################################################\r
+    # iterator\r
+    ###############################################################################################\r
+    int                 PyIter_Check                    (object)                    # Always succeeds.\r
+    object              PyIter_Next                     (object)\r
+\r
+    ###############################################################################################\r
+    # list\r
+    ###############################################################################################\r
+    PyTypeObject PyList_Type\r
+    int                 PyList_Append                   (object, object)            except -1\r
+    object              PyList_AsTuple                  (object)\r
+    int                 PyList_Check                    (object)                    # Always succeeds.\r
+    int                 PyList_CheckExact               (object)                    # Always succeeds.\r
+    int                 PyList_GET_SIZE                 (object)                    # Always suceeds.\r
+    object              PyList_GetSlice                 (object, Py_ssize_t, Py_ssize_t)\r
+    int                 PyList_Insert                   (object, Py_ssize_t, object)       except -1\r
+    object              PyList_New                      (Py_ssize_t)\r
+    int                 PyList_Reverse                  (object)                    except -1\r
+    int                 PyList_SetSlice                 (object, Py_ssize_t, Py_ssize_t, object)  except -1\r
+    Py_ssize_t          PyList_Size                     (object)                    except -1\r
+    int                 PyList_Sort                     (object)                    except -1\r
+\r
+    ###############################################################################################\r
+    # long\r
+    ###############################################################################################\r
+    PyTypeObject PyLong_Type\r
+    int                 _PyLong_AsByteArray             (object, unsigned char *, size_t, int, int) except -1\r
+    object              _PyLong_FromByteArray           (unsigned char *, size_t, int, int)\r
+    size_t              _PyLong_NumBits                 (object)                    except -1\r
+    int                 _PyLong_Sign                    (object)                    # No error.\r
+    long                PyLong_AsLong                   (object)                    except? -1\r
+    long long           PyLong_AsLongLong               (object)                    except? -1\r
+    unsigned long       PyLong_AsUnsignedLong           (object)                    except? -1\r
+    unsigned long       PyLong_AsUnsignedLongMask       (object)                    except? -1\r
+    unsigned long long  PyLong_AsUnsignedLongLong       (object)                    except? -1\r
+    unsigned long long  PyLong_AsUnsignedLongLongMask   (object)                    except? -1\r
+    int                 PyLong_Check                    (object)                    # Always succeeds.\r
+    int                 PyLong_CheckExact               (object)                    # Always succeeds.\r
+    object              PyLong_FromDouble               (double)\r
+    object              PyLong_FromLong                 (long)\r
+    object              PyLong_FromLongLong             (long long)\r
+    object              PyLong_FromUnsignedLong         (unsigned long)\r
+    object              PyLong_FromUnsignedLongLong     (unsigned long long)\r
+    double              PyLong_AsDouble                 (object)                    except? -1\r
+    object              PyLong_FromVoidPtr              (void *)\r
+    void *              PyLong_AsVoidPtr                (object)                    except NULL\r
+    object              PyLong_FromString               (char *, char **, int)\r
+    object              PyLong_FromUnicode              (Py_UNICODE*, Py_ssize_t, int)\r
+\r
+    ###############################################################################################\r
+    # mapping\r
+    ###############################################################################################\r
+    int                 PyMapping_Check                 (object)                    # Always succeeds.\r
+    int                 PyMapping_DelItem               (object, object)            except -1\r
+    int                 PyMapping_DelItemString         (object, char *)            except -1\r
+    object              PyMapping_GetItemString         (object, char *)\r
+    int                 PyMapping_HasKey                (object, object)            # Always succeeds.\r
+    int                 PyMapping_HasKeyString          (object, char *)            # Always succeeds.\r
+    object              PyMapping_Items                 (object)\r
+    object              PyMapping_Keys                  (object)\r
+    Py_ssize_t          PyMapping_Length                (object)                    except -1\r
+    int                 PyMapping_SetItemString         (object, char *, object)    except -1\r
+    Py_ssize_t          PyMapping_Size                  (object)                    except -1\r
+    object              PyMapping_Values                (object)\r
+\r
+    ###############################################################################################\r
+    # mem\r
+    ###############################################################################################\r
+    void                PyMem_Free                      (void * p)\r
+    void *              PyMem_Malloc                    (size_t n)\r
+    void *              PyMem_Realloc                   (void *, size_t)\r
+\r
+    ###############################################################################################\r
+    # modsupport\r
+    ###############################################################################################\r
+    object              Py_BuildValue                   (char *, ...)\r
+    object              Py_VaBuildValue                 (char *, va_list)\r
+\r
+    ###############################################################################################\r
+    # number\r
+    ###############################################################################################\r
+    object              PyNumber_Absolute               (object)\r
+    object              PyNumber_Add                    (object, object)\r
+    object              PyNumber_And                    (object, object)\r
+    Py_ssize_t          PyNumber_AsSsize_t              (object, object)    except? -1\r
+    int                 PyNumber_Check                  (object)                    # Always succeeds.\r
+    # XXX: Pyrex doesn't support pointer to python object?\r
+    #int                 PyNumber_Coerce                 (object*, object*)          except -1\r
+    object              PyNumber_Divide                 (object, object)\r
+    object              PyNumber_Divmod                 (object, object)\r
+    object              PyNumber_Float                  (object)\r
+    object              PyNumber_FloorDivide            (object, object)\r
+    object              PyNumber_InPlaceAdd             (object, object)\r
+    object              PyNumber_InPlaceAnd             (object, object)\r
+    object              PyNumber_InPlaceDivide          (object, object)\r
+    object              PyNumber_InPlaceFloorDivide     (object, object)\r
+    object              PyNumber_InPlaceLshift          (object, object)\r
+    object              PyNumber_InPlaceMultiply        (object, object)\r
+    object              PyNumber_InPlaceOr              (object, object)\r
+    object              PyNumber_InPlacePower           (object, object, object)\r
+    object              PyNumber_InPlaceRemainder       (object, object)\r
+    object              PyNumber_InPlaceRshift          (object, object)\r
+    object              PyNumber_InPlaceSubtract        (object, object)\r
+    object              PyNumber_InPlaceTrueDivide      (object, object)\r
+    object              PyNumber_InPlaceXor             (object, object)\r
+    object              PyNumber_Int                    (object)\r
+    object              PyNumber_Invert                 (object)\r
+    object              PyNumber_Long                   (object)\r
+    object              PyNumber_Lshift                 (object, object)\r
+    object              PyNumber_Multiply               (object, object)\r
+    object              PyNumber_Negative               (object)\r
+    object              PyNumber_Or                     (object, object)\r
+    object              PyNumber_Positive               (object)\r
+    object              PyNumber_Power                  (object, object, object)\r
+    object              PyNumber_Remainder              (object, object)\r
+    object              PyNumber_Rshift                 (object, object)\r
+    object              PyNumber_Subtract               (object, object)\r
+    object              PyNumber_TrueDivide             (object, object)\r
+    object              PyNumber_Xor                    (object, object)\r
+\r
+    ###############################################################################################\r
+    # object\r
+    ###############################################################################################\r
+    int                 PyCallable_Check                (object)                    # Always succeeds.\r
+    int                 PyObject_AsFileDescriptor       (object)                    except -1\r
+    object              PyObject_Call                   (object, object, object)\r
+    object              PyObject_CallFunction           (object, char *, ...)\r
+    object              PyObject_CallFunctionObjArgs    (object, ...)\r
+    object              PyObject_CallMethod             (object, char *, char *, ...)\r
+    object              PyObject_CallMethodObjArgs      (object, object, ...)\r
+    object              PyObject_CallObject             (object, object)\r
+    int                 PyObject_Cmp                    (object, object, int *result)   except -1\r
+    # Use PyObject_Cmp instead.\r
+    #int                 PyObject_Compare                (object, object)\r
+    int                 PyObject_DelAttr                (object, object)            except -1\r
+    int                 PyObject_DelAttrString          (object, char *)            except -1\r
+    int                 PyObject_DelItem                (object, object)            except -1\r
+    int                 PyObject_DelItemString          (object, char *)            except -1\r
+    object              PyObject_Dir                    (object)\r
+    object              PyObject_GetAttr                (object, object)\r
+    object              PyObject_GetAttrString          (object, char *)\r
+    object              PyObject_GetItem                (object, object)\r
+    object              PyObject_GetIter                (object)\r
+    int                 PyObject_HasAttr                (object, object)            # Always succeeds.\r
+    int                 PyObject_HasAttrString          (object, char *)            # Always succeeds.\r
+    long                PyObject_Hash                   (object)                    except -1\r
+    int                 PyObject_IsInstance             (object, object)            except -1\r
+    int                 PyObject_IsSubclass             (object, object)            except -1\r
+    int                 PyObject_IsTrue                 (object)                    except -1\r
+    Py_ssize_t          PyObject_Length                 (object)                    except -1\r
+    int                 PyObject_Not                    (object)                    except -1\r
+    int                 PyObject_Print                  (object, FILE *, int)       except -1\r
+    object              PyObject_Repr                   (object)\r
+    object              PyObject_RichCompare            (object, object, int)\r
+    int                 PyObject_RichCompareBool        (object, object, int)       except -1\r
+    int                 PyObject_SetAttr                (object, object, object)    except -1\r
+    int                 PyObject_SetAttrString          (object, char *, object)    except -1\r
+    int                 PyObject_SetItem                (object, object, object)    except -1\r
+    Py_ssize_t          PyObject_Size                   (object)                    except -1\r
+    object              PyObject_Str                    (object)\r
+    object              PyObject_Type                   (object)\r
+    int                 PyObject_TypeCheck              (object, object)            # Always succeeds.\r
+    object              PyObject_Unicode                (object)\r
+\r
+    ###############################################################################################\r
+    # pyerrors\r
+    ###############################################################################################\r
+    int                 PyErr_BadArgument               ()\r
+    void                PyErr_BadInternalCall           ()\r
+    int                 PyErr_CheckSignals              ()\r
+    void                PyErr_Clear                     ()\r
+    int                 PyErr_ExceptionMatches          (object)\r
+    object              PyErr_Format                    (object, char *, ...)\r
+    int                 PyErr_GivenExceptionMatches     (object, object)\r
+    object              PyErr_NoMemory                  ()\r
+    object              PyErr_Occurred                  ()\r
+    void                PyErr_Restore                   (object, object, object)\r
+    object              PyErr_SetFromErrno              (object)\r
+    object              PyErr_SetFromErrnoWithFilename  (object, char *)\r
+    object              PyErr_SetFromErrnoWithFilenameObject    (object, object)\r
+    void                PyErr_SetInterrupt              ()\r
+    void                PyErr_SetNone                   (object)\r
+    void                PyErr_SetObject                 (object, object)\r
+    void                PyErr_SetString                 (object, char *)\r
+    int                 PyErr_Warn                      (object, char *)\r
+    int                 PyErr_WarnExplicit              (object, char *, char *, int, char *, object)\r
+    void                PyErr_WriteUnraisable           (object)\r
+\r
+    ###############################################################################################\r
+    # pyeval\r
+    # Be extremely careful with these functions.\r
+    ###############################################################################################\r
+\r
+    ctypedef struct PyThreadState:\r
+        PyFrameObject * frame\r
+        int recursion_depth\r
+        void * curexc_type, * curexc_value, * curexc_traceback\r
+        void * exc_type, * exc_value, * exc_traceback\r
+\r
+    void                PyEval_AcquireLock              ()\r
+    void                PyEval_ReleaseLock              ()\r
+    void                PyEval_AcquireThread            (PyThreadState *)\r
+    void                PyEval_ReleaseThread            (PyThreadState *)\r
+    PyThreadState*      PyEval_SaveThread               ()\r
+    void                PyEval_RestoreThread            (PyThreadState *)\r
+\r
+    ###############################################################################################\r
+    # pystate\r
+    # Be extremely careful with these functions.  Read PEP 311 for more detail.\r
+    ###############################################################################################\r
+\r
+    ctypedef int PyGILState_STATE\r
+    PyGILState_STATE    PyGILState_Ensure               ()\r
+    void                PyGILState_Release              (PyGILState_STATE)\r
+\r
+    ctypedef struct PyInterpreterState:\r
+        pass\r
+\r
+    PyThreadState*      PyThreadState_New               (PyInterpreterState *)\r
+    void                PyThreadState_Clear             (PyThreadState *)\r
+    void                PyThreadState_Delete            (PyThreadState *)\r
+    PyThreadState*      PyThreadState_Get               ()\r
+    PyThreadState*      PyThreadState_Swap              (PyThreadState *tstate)\r
+    # XXX: Borrowed reference.\r
+    #object              PyThreadState_GetDict          ()\r
+\r
+    ###############################################################################################\r
+    # run\r
+    # Functions for embedded interpreters are not included.\r
+    ###############################################################################################\r
+    ctypedef struct PyCompilerFlags:\r
+        int cf_flags\r
+\r
+    ctypedef struct _node:\r
+        pass\r
+\r
+    ctypedef void (*PyOS_sighandler_t)(int)\r
+\r
+    void                PyErr_Display                   (object, object, object)\r
+    void                PyErr_Print                     ()\r
+    void                PyErr_PrintEx                   (int)\r
+    char *              PyOS_Readline                   (FILE *, FILE *, char *)\r
+    PyOS_sighandler_t   PyOS_getsig                     (int)\r
+    PyOS_sighandler_t   PyOS_setsig                     (int, PyOS_sighandler_t)\r
+    _node *             PyParser_SimpleParseFile        (FILE *, char *, int)       except NULL\r
+    _node *             PyParser_SimpleParseFileFlags   (FILE *, char *, int,\r
+                                                         int)                       except NULL\r
+    _node *             PyParser_SimpleParseString      (char *, int)               except NULL\r
+    _node *             PyParser_SimpleParseStringFlagsFilename(char *, char *,\r
+                                                         int, int)                  except NULL\r
+    _node *             PyParser_SimpleParseStringFlags (char *, int, int)          except NULL\r
+    int                 PyRun_AnyFile                   (FILE *, char *)            except -1\r
+    int                 PyRun_AnyFileEx                 (FILE *, char *, int)       except -1\r
+    int                 PyRun_AnyFileExFlags            (FILE *, char *, int,\r
+                                                         PyCompilerFlags *)         except -1\r
+    int                 PyRun_AnyFileFlags              (FILE *, char *,\r
+                                                         PyCompilerFlags *)         except -1\r
+    object              PyRun_File                      (FILE *, char *, int,\r
+                                                         object, object)\r
+    object              PyRun_FileEx                    (FILE *, char *, int,\r
+                                                         object, object, int)\r
+    object              PyRun_FileExFlags               (FILE *, char *, int,\r
+                                                         object, object, int,\r
+                                                         PyCompilerFlags *)\r
+    object              PyRun_FileFlags                 (FILE *, char *, int,\r
+                                                         object, object,\r
+                                                         PyCompilerFlags *)\r
+    int                 PyRun_InteractiveLoop           (FILE *, char *)            except -1\r
+    int                 PyRun_InteractiveLoopFlags      (FILE *, char *,\r
+                                                         PyCompilerFlags *)         except -1\r
+    int                 PyRun_InteractiveOne            (FILE *, char *)            except -1\r
+    int                 PyRun_InteractiveOneFlags       (FILE *, char *,\r
+                                                         PyCompilerFlags *)         except -1\r
+    int                 PyRun_SimpleFile                (FILE *, char *)            except -1\r
+    int                 PyRun_SimpleFileEx              (FILE *, char *, int)       except -1\r
+    int                 PyRun_SimpleFileExFlags         (FILE *, char *, int,\r
+                                                         PyCompilerFlags *)         except -1\r
+    int                 PyRun_SimpleString              (char *)                    except -1\r
+    int                 PyRun_SimpleStringFlags         (char *, PyCompilerFlags *) except -1\r
+    object              PyRun_String                    (char *, int, object,\r
+                                                         object)\r
+    object              PyRun_StringFlags               (char *, int, object,\r
+                                                         object, PyCompilerFlags *)\r
+    int                 Py_AtExit                       (void (*func)())\r
+    object              Py_CompileString                (char *, char *, int)\r
+    object              Py_CompileStringFlags           (char *, char *, int, PyCompilerFlags *)\r
+    void                Py_Exit                         (int)\r
+    int                 Py_FdIsInteractive              (FILE *, char *)            # Always succeeds.\r
+    char *              Py_GetBuildInfo                 ()\r
+    char *              Py_GetCompiler                  ()\r
+    char *              Py_GetCopyright                 ()\r
+    char *              Py_GetExecPrefix                ()\r
+    char *              Py_GetPath                      ()\r
+    char *              Py_GetPlatform                  ()\r
+    char *              Py_GetPrefix                    ()\r
+    char *              Py_GetProgramFullPath           ()\r
+    char *              Py_GetProgramName               ()\r
+    char *              Py_GetPythonHome                ()\r
+    char *              Py_GetVersion                   ()\r
+\r
+    ###############################################################################################\r
+    # sequence\r
+    ###############################################################################################\r
+    int                 PySequence_Check                (object)                    # Always succeeds.\r
+    object              PySequence_Concat               (object, object)\r
+    int                 PySequence_Contains             (object, object)            except -1\r
+    Py_ssize_t          PySequence_Count                (object, object)            except -1\r
+    int                 PySequence_DelItem              (object, Py_ssize_t)        except -1\r
+    int                 PySequence_DelSlice             (object, Py_ssize_t, Py_ssize_t) except -1\r
+    object              PySequence_Fast                 (object, char *)\r
+    int                 PySequence_Fast_GET_SIZE        (object)\r
+    object              PySequence_GetItem              (object, Py_ssize_t)\r
+    object              PySequence_GetSlice             (object, Py_ssize_t, Py_ssize_t)\r
+    object              PySequence_ITEM                 (object, int)\r
+    int                 PySequence_In                   (object, object)            except -1\r
+    object              PySequence_InPlaceConcat        (object, object)\r
+    object              PySequence_InPlaceRepeat        (object, Py_ssize_t)\r
+    Py_ssize_t          PySequence_Index                (object, object)            except -1\r
+    Py_ssize_t          PySequence_Length               (object)                    except -1\r
+    object              PySequence_List                 (object)\r
+    object              PySequence_Repeat               (object, Py_ssize_t)\r
+    int                 PySequence_SetItem              (object, Py_ssize_t, object) except -1\r
+    int                 PySequence_SetSlice             (object, Py_ssize_t, Py_ssize_t, object) except -1\r
+    Py_ssize_t          PySequence_Size                 (object)                    except -1\r
+    object              PySequence_Tuple                (object)\r
+\r
+    ###############################################################################################\r
+    # string\r
+    ###############################################################################################\r
+    PyTypeObject PyString_Type\r
+    # Pyrex cannot support resizing because you have no choice but to use\r
+    # realloc which may call free() on the object, and there's no way to tell\r
+    # Pyrex to "forget" reference counting for the object.\r
+    #int                 _PyString_Resize                (object *, Py_ssize_t)             except -1\r
+    char *              PyString_AS_STRING              (object)                    # Always succeeds.\r
+    object              PyString_AsDecodedObject        (object, char *, char *)\r
+    object              PyString_AsEncodedObject        (object, char *, char *)\r
+    object              PyString_AsEncodedString        (object, char *, char *)\r
+    char *              PyString_AsString               (object)                    except NULL\r
+    int                 PyString_AsStringAndSize        (object, char **, Py_ssize_t *)    except -1\r
+    int                 PyString_Check                  (object)                    # Always succeeds.\r
+    int                 PyString_CHECK_INTERNED         (object)                    # Always succeeds.\r
+    int                 PyString_CheckExact             (object)                    # Always succeeds.\r
+    # XXX: Pyrex doesn't support pointer to a python object?\r
+    #void                PyString_Concat                 (object *, object)\r
+    # XXX: Pyrex doesn't support pointer to a python object?\r
+    #void                PyString_ConcatAndDel           (object *, object)\r
+    object              PyString_Decode                 (char *, int, char *, char *)\r
+    object              PyString_DecodeEscape           (char *, int, char *, int, char *)\r
+    object              PyString_Encode                 (char *, int, char *, char *)\r
+    object              PyString_Format                 (object, object)\r
+    object              PyString_FromFormat             (char*, ...)\r
+    object              PyString_FromFormatV            (char*, va_list)\r
+    object              PyString_FromString             (char *)\r
+    object              PyString_FromStringAndSize      (char *, Py_ssize_t)\r
+    Py_ssize_t          PyString_GET_SIZE               (object)                    # Always succeeds.\r
+    object              PyString_InternFromString       (char *)\r
+    # XXX: Pyrex doesn't support pointer to a python object?\r
+    #void                PyString_InternImmortal         (object*)\r
+    # XXX: Pyrex doesn't support pointer to a python object?\r
+    #void                PyString_InternInPlace          (object*)\r
+    object              PyString_Repr                   (object, int)\r
+    Py_ssize_t          PyString_Size                   (object)                    except -1\r
+\r
+    # Disgusting hack to access internal object values.\r
+    ctypedef struct PyStringObject:\r
+        int ob_refcnt\r
+        PyTypeObject * ob_type\r
+        int ob_size\r
+        long ob_shash\r
+        int ob_sstate\r
+        char * ob_sval\r
+\r
+    ###############################################################################################\r
+    # tuple\r
+    ###############################################################################################\r
+    PyTypeObject PyTuple_Type\r
+    # See PyString_Resize note about resizing.\r
+    #int                 _PyTuple_Resize                 (object*, Py_ssize_t)              except -1\r
+    int                 PyTuple_Check                   (object)                    # Always succeeds.\r
+    int                 PyTuple_CheckExact              (object)                    # Always succeeds.\r
+    Py_ssize_t          PyTuple_GET_SIZE                (object)                    # Always succeeds.\r
+    object              PyTuple_GetSlice                (object, Py_ssize_t, Py_ssize_t)\r
+    object              PyTuple_New                     (Py_ssize_t)\r
+    object              PyTuple_Pack                    (Py_ssize_t, ...)\r
+    Py_ssize_t          PyTuple_Size                    (object)                    except -1\r
+\r
+    ###############################################################################################\r
+    # Dangerous things!\r
+    # Do not use these unless you really, really know what you are doing.\r
+    ###############################################################################################\r
+    void                Py_INCREF                       (object)\r
+    void                Py_XINCREF                      (object)\r
+    void                Py_DECREF                       (object)\r
+    void                Py_XDECREF                      (object)\r
+    void                Py_CLEAR                        (object)\r
+\r
+    # XXX: Stolen reference.\r
+    void                PyTuple_SET_ITEM                (object, Py_ssize_t, value)\r
+    # XXX: Borrowed reference.\r
+    object              PyTuple_GET_ITEM                (object, Py_ssize_t)\r
+    # XXX: Borrowed reference.\r
+    object              PyTuple_GetItem                 (object, Py_ssize_t)\r
+    # XXX: Stolen reference.\r
+    int                 PyTuple_SetItem                 (object, Py_ssize_t, object)       except -1\r
+\r
+    # XXX: Steals reference.\r
+    int                 PyList_SetItem                  (object, Py_ssize_t, object)       except -1\r
+    # XXX: Borrowed reference\r
+    object              PyList_GetItem                  (object, Py_ssize_t)\r
+    # XXX: Borrowed reference, no NULL on error.\r
+    object              PyList_GET_ITEM                 (object, Py_ssize_t)\r
+    # XXX: Stolen reference.\r
+    void                PyList_SET_ITEM                 (object, Py_ssize_t, object)\r
+\r
+    # XXX: Borrowed reference.\r
+    object              PySequence_Fast_GET_ITEM        (object, Py_ssize_t)\r
+\r
+    # First parameter _must_ be a PyStringObject.\r
+    object              _PyString_Join                  (object, object)\r