14710c53dcad1ebf3755f3efb9e80ac24bd72a9b2darylm#ifndef Py_ABSTRACTOBJECT_H
24710c53dcad1ebf3755f3efb9e80ac24bd72a9b2darylm#define Py_ABSTRACTOBJECT_H
34710c53dcad1ebf3755f3efb9e80ac24bd72a9b2darylm#ifdef __cplusplus
44710c53dcad1ebf3755f3efb9e80ac24bd72a9b2darylmextern "C" {
54710c53dcad1ebf3755f3efb9e80ac24bd72a9b2darylm#endif
64710c53dcad1ebf3755f3efb9e80ac24bd72a9b2darylm
74710c53dcad1ebf3755f3efb9e80ac24bd72a9b2darylm#ifdef PY_SSIZE_T_CLEAN
84710c53dcad1ebf3755f3efb9e80ac24bd72a9b2darylm#define PyObject_CallFunction _PyObject_CallFunction_SizeT
94710c53dcad1ebf3755f3efb9e80ac24bd72a9b2darylm#define PyObject_CallMethod _PyObject_CallMethod_SizeT
104710c53dcad1ebf3755f3efb9e80ac24bd72a9b2darylm#endif
114710c53dcad1ebf3755f3efb9e80ac24bd72a9b2darylm
124710c53dcad1ebf3755f3efb9e80ac24bd72a9b2darylm/* Abstract Object Interface (many thanks to Jim Fulton) */
134710c53dcad1ebf3755f3efb9e80ac24bd72a9b2darylm
144710c53dcad1ebf3755f3efb9e80ac24bd72a9b2darylm/*
154710c53dcad1ebf3755f3efb9e80ac24bd72a9b2darylm   PROPOSAL: A Generic Python Object Interface for Python C Modules
164710c53dcad1ebf3755f3efb9e80ac24bd72a9b2darylm
174710c53dcad1ebf3755f3efb9e80ac24bd72a9b2darylmProblem
184710c53dcad1ebf3755f3efb9e80ac24bd72a9b2darylm
194710c53dcad1ebf3755f3efb9e80ac24bd72a9b2darylm  Python modules written in C that must access Python objects must do
204710c53dcad1ebf3755f3efb9e80ac24bd72a9b2darylm  so through routines whose interfaces are described by a set of
214710c53dcad1ebf3755f3efb9e80ac24bd72a9b2darylm  include files.  Unfortunately, these routines vary according to the
224710c53dcad1ebf3755f3efb9e80ac24bd72a9b2darylm  object accessed.  To use these routines, the C programmer must check
234710c53dcad1ebf3755f3efb9e80ac24bd72a9b2darylm  the type of the object being used and must call a routine based on
244710c53dcad1ebf3755f3efb9e80ac24bd72a9b2darylm  the object type.  For example, to access an element of a sequence,
254710c53dcad1ebf3755f3efb9e80ac24bd72a9b2darylm  the programmer must determine whether the sequence is a list or a
264710c53dcad1ebf3755f3efb9e80ac24bd72a9b2darylm  tuple:
274710c53dcad1ebf3755f3efb9e80ac24bd72a9b2darylm
284710c53dcad1ebf3755f3efb9e80ac24bd72a9b2darylm    if(is_tupleobject(o))
294710c53dcad1ebf3755f3efb9e80ac24bd72a9b2darylm      e=gettupleitem(o,i)
304710c53dcad1ebf3755f3efb9e80ac24bd72a9b2darylm    else if(is_listitem(o))
314710c53dcad1ebf3755f3efb9e80ac24bd72a9b2darylm      e=getlistitem(o,i)
324710c53dcad1ebf3755f3efb9e80ac24bd72a9b2darylm
334710c53dcad1ebf3755f3efb9e80ac24bd72a9b2darylm  If the programmer wants to get an item from another type of object
344710c53dcad1ebf3755f3efb9e80ac24bd72a9b2darylm  that provides sequence behavior, there is no clear way to do it
354710c53dcad1ebf3755f3efb9e80ac24bd72a9b2darylm  correctly.
364710c53dcad1ebf3755f3efb9e80ac24bd72a9b2darylm
374710c53dcad1ebf3755f3efb9e80ac24bd72a9b2darylm  The persistent programmer may peruse object.h and find that the
384710c53dcad1ebf3755f3efb9e80ac24bd72a9b2darylm  _typeobject structure provides a means of invoking up to (currently
394710c53dcad1ebf3755f3efb9e80ac24bd72a9b2darylm  about) 41 special operators.  So, for example, a routine can get an
404710c53dcad1ebf3755f3efb9e80ac24bd72a9b2darylm  item from any object that provides sequence behavior. However, to
414710c53dcad1ebf3755f3efb9e80ac24bd72a9b2darylm  use this mechanism, the programmer must make their code dependent on
424710c53dcad1ebf3755f3efb9e80ac24bd72a9b2darylm  the current Python implementation.
434710c53dcad1ebf3755f3efb9e80ac24bd72a9b2darylm
444710c53dcad1ebf3755f3efb9e80ac24bd72a9b2darylm  Also, certain semantics, especially memory management semantics, may
454710c53dcad1ebf3755f3efb9e80ac24bd72a9b2darylm  differ by the type of object being used.  Unfortunately, these
464710c53dcad1ebf3755f3efb9e80ac24bd72a9b2darylm  semantics are not clearly described in the current include files.
474710c53dcad1ebf3755f3efb9e80ac24bd72a9b2darylm  An abstract interface providing more consistent semantics is needed.
484710c53dcad1ebf3755f3efb9e80ac24bd72a9b2darylm
494710c53dcad1ebf3755f3efb9e80ac24bd72a9b2darylmProposal
504710c53dcad1ebf3755f3efb9e80ac24bd72a9b2darylm
514710c53dcad1ebf3755f3efb9e80ac24bd72a9b2darylm  I propose the creation of a standard interface (with an associated
524710c53dcad1ebf3755f3efb9e80ac24bd72a9b2darylm  library of routines and/or macros) for generically obtaining the
534710c53dcad1ebf3755f3efb9e80ac24bd72a9b2darylm  services of Python objects.  This proposal can be viewed as one
544710c53dcad1ebf3755f3efb9e80ac24bd72a9b2darylm  components of a Python C interface consisting of several components.
554710c53dcad1ebf3755f3efb9e80ac24bd72a9b2darylm
564710c53dcad1ebf3755f3efb9e80ac24bd72a9b2darylm  From the viewpoint of C access to Python services, we have (as
574710c53dcad1ebf3755f3efb9e80ac24bd72a9b2darylm  suggested by Guido in off-line discussions):
584710c53dcad1ebf3755f3efb9e80ac24bd72a9b2darylm
594710c53dcad1ebf3755f3efb9e80ac24bd72a9b2darylm  - "Very high level layer": two or three functions that let you exec or
604710c53dcad1ebf3755f3efb9e80ac24bd72a9b2darylm    eval arbitrary Python code given as a string in a module whose name is
614710c53dcad1ebf3755f3efb9e80ac24bd72a9b2darylm    given, passing C values in and getting C values out using
624710c53dcad1ebf3755f3efb9e80ac24bd72a9b2darylm    mkvalue/getargs style format strings.  This does not require the user
634710c53dcad1ebf3755f3efb9e80ac24bd72a9b2darylm    to declare any variables of type "PyObject *".  This should be enough
644710c53dcad1ebf3755f3efb9e80ac24bd72a9b2darylm    to write a simple application that gets Python code from the user,
654710c53dcad1ebf3755f3efb9e80ac24bd72a9b2darylm    execs it, and returns the output or errors.  (Error handling must also
664710c53dcad1ebf3755f3efb9e80ac24bd72a9b2darylm    be part of this API.)
674710c53dcad1ebf3755f3efb9e80ac24bd72a9b2darylm
684710c53dcad1ebf3755f3efb9e80ac24bd72a9b2darylm  - "Abstract objects layer": which is the subject of this proposal.
694710c53dcad1ebf3755f3efb9e80ac24bd72a9b2darylm    It has many functions operating on objects, and lest you do many
704710c53dcad1ebf3755f3efb9e80ac24bd72a9b2darylm    things from C that you can also write in Python, without going
714710c53dcad1ebf3755f3efb9e80ac24bd72a9b2darylm    through the Python parser.
724710c53dcad1ebf3755f3efb9e80ac24bd72a9b2darylm
734710c53dcad1ebf3755f3efb9e80ac24bd72a9b2darylm  - "Concrete objects layer": This is the public type-dependent
744710c53dcad1ebf3755f3efb9e80ac24bd72a9b2darylm    interface provided by the standard built-in types, such as floats,
754710c53dcad1ebf3755f3efb9e80ac24bd72a9b2darylm    strings, and lists.  This interface exists and is currently
764710c53dcad1ebf3755f3efb9e80ac24bd72a9b2darylm    documented by the collection of include files provided with the
774710c53dcad1ebf3755f3efb9e80ac24bd72a9b2darylm    Python distributions.
784710c53dcad1ebf3755f3efb9e80ac24bd72a9b2darylm
794710c53dcad1ebf3755f3efb9e80ac24bd72a9b2darylm  From the point of view of Python accessing services provided by C
804710c53dcad1ebf3755f3efb9e80ac24bd72a9b2darylm  modules:
814710c53dcad1ebf3755f3efb9e80ac24bd72a9b2darylm
824710c53dcad1ebf3755f3efb9e80ac24bd72a9b2darylm  - "Python module interface": this interface consist of the basic
834710c53dcad1ebf3755f3efb9e80ac24bd72a9b2darylm    routines used to define modules and their members.  Most of the
844710c53dcad1ebf3755f3efb9e80ac24bd72a9b2darylm    current extensions-writing guide deals with this interface.
854710c53dcad1ebf3755f3efb9e80ac24bd72a9b2darylm
864710c53dcad1ebf3755f3efb9e80ac24bd72a9b2darylm  - "Built-in object interface": this is the interface that a new
874710c53dcad1ebf3755f3efb9e80ac24bd72a9b2darylm    built-in type must provide and the mechanisms and rules that a
884710c53dcad1ebf3755f3efb9e80ac24bd72a9b2darylm    developer of a new built-in type must use and follow.
894710c53dcad1ebf3755f3efb9e80ac24bd72a9b2darylm
904710c53dcad1ebf3755f3efb9e80ac24bd72a9b2darylm  This proposal is a "first-cut" that is intended to spur
914710c53dcad1ebf3755f3efb9e80ac24bd72a9b2darylm  discussion. See especially the lists of notes.
924710c53dcad1ebf3755f3efb9e80ac24bd72a9b2darylm
934710c53dcad1ebf3755f3efb9e80ac24bd72a9b2darylm  The Python C object interface will provide four protocols: object,
944710c53dcad1ebf3755f3efb9e80ac24bd72a9b2darylm  numeric, sequence, and mapping.  Each protocol consists of a
954710c53dcad1ebf3755f3efb9e80ac24bd72a9b2darylm  collection of related operations.  If an operation that is not
964710c53dcad1ebf3755f3efb9e80ac24bd72a9b2darylm  provided by a particular type is invoked, then a standard exception,
974710c53dcad1ebf3755f3efb9e80ac24bd72a9b2darylm  NotImplementedError is raised with a operation name as an argument.
984710c53dcad1ebf3755f3efb9e80ac24bd72a9b2darylm  In addition, for convenience this interface defines a set of
994710c53dcad1ebf3755f3efb9e80ac24bd72a9b2darylm  constructors for building objects of built-in types.  This is needed
1004710c53dcad1ebf3755f3efb9e80ac24bd72a9b2darylm  so new objects can be returned from C functions that otherwise treat
1014710c53dcad1ebf3755f3efb9e80ac24bd72a9b2darylm  objects generically.
1024710c53dcad1ebf3755f3efb9e80ac24bd72a9b2darylm
1034710c53dcad1ebf3755f3efb9e80ac24bd72a9b2darylmMemory Management
1044710c53dcad1ebf3755f3efb9e80ac24bd72a9b2darylm
1054710c53dcad1ebf3755f3efb9e80ac24bd72a9b2darylm  For all of the functions described in this proposal, if a function
1064710c53dcad1ebf3755f3efb9e80ac24bd72a9b2darylm  retains a reference to a Python object passed as an argument, then the
1074710c53dcad1ebf3755f3efb9e80ac24bd72a9b2darylm  function will increase the reference count of the object.  It is
1084710c53dcad1ebf3755f3efb9e80ac24bd72a9b2darylm  unnecessary for the caller to increase the reference count of an
1094710c53dcad1ebf3755f3efb9e80ac24bd72a9b2darylm  argument in anticipation of the object's retention.
1104710c53dcad1ebf3755f3efb9e80ac24bd72a9b2darylm
1114710c53dcad1ebf3755f3efb9e80ac24bd72a9b2darylm  All Python objects returned from functions should be treated as new
1124710c53dcad1ebf3755f3efb9e80ac24bd72a9b2darylm  objects.  Functions that return objects assume that the caller will
1134710c53dcad1ebf3755f3efb9e80ac24bd72a9b2darylm  retain a reference and the reference count of the object has already
1144710c53dcad1ebf3755f3efb9e80ac24bd72a9b2darylm  been incremented to account for this fact.  A caller that does not
1154710c53dcad1ebf3755f3efb9e80ac24bd72a9b2darylm  retain a reference to an object that is returned from a function
1164710c53dcad1ebf3755f3efb9e80ac24bd72a9b2darylm  must decrement the reference count of the object (using
1174710c53dcad1ebf3755f3efb9e80ac24bd72a9b2darylm  DECREF(object)) to prevent memory leaks.
1184710c53dcad1ebf3755f3efb9e80ac24bd72a9b2darylm
1194710c53dcad1ebf3755f3efb9e80ac24bd72a9b2darylm  Note that the behavior mentioned here is different from the current
1204710c53dcad1ebf3755f3efb9e80ac24bd72a9b2darylm  behavior for some objects (e.g. lists and tuples) when certain
1214710c53dcad1ebf3755f3efb9e80ac24bd72a9b2darylm  type-specific routines are called directly (e.g. setlistitem).  The
1224710c53dcad1ebf3755f3efb9e80ac24bd72a9b2darylm  proposed abstraction layer will provide a consistent memory
1234710c53dcad1ebf3755f3efb9e80ac24bd72a9b2darylm  management interface, correcting for inconsistent behavior for some
1244710c53dcad1ebf3755f3efb9e80ac24bd72a9b2darylm  built-in types.
1254710c53dcad1ebf3755f3efb9e80ac24bd72a9b2darylm
1264710c53dcad1ebf3755f3efb9e80ac24bd72a9b2darylmProtocols
1274710c53dcad1ebf3755f3efb9e80ac24bd72a9b2darylm
1284710c53dcad1ebf3755f3efb9e80ac24bd72a9b2darylmxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx*/
1294710c53dcad1ebf3755f3efb9e80ac24bd72a9b2darylm
1304710c53dcad1ebf3755f3efb9e80ac24bd72a9b2darylm/*  Object Protocol: */
1314710c53dcad1ebf3755f3efb9e80ac24bd72a9b2darylm
1324710c53dcad1ebf3755f3efb9e80ac24bd72a9b2darylm     /* Implemented elsewhere:
1334710c53dcad1ebf3755f3efb9e80ac24bd72a9b2darylm
1344710c53dcad1ebf3755f3efb9e80ac24bd72a9b2darylm     int PyObject_Print(PyObject *o, FILE *fp, int flags);
1354710c53dcad1ebf3755f3efb9e80ac24bd72a9b2darylm
1364710c53dcad1ebf3755f3efb9e80ac24bd72a9b2darylm     Print an object, o, on file, fp.  Returns -1 on
1374710c53dcad1ebf3755f3efb9e80ac24bd72a9b2darylm     error.  The flags argument is used to enable certain printing
1384710c53dcad1ebf3755f3efb9e80ac24bd72a9b2darylm     options. The only option currently supported is Py_Print_RAW.
1394710c53dcad1ebf3755f3efb9e80ac24bd72a9b2darylm
1404710c53dcad1ebf3755f3efb9e80ac24bd72a9b2darylm     (What should be said about Py_Print_RAW?)
1414710c53dcad1ebf3755f3efb9e80ac24bd72a9b2darylm
1424710c53dcad1ebf3755f3efb9e80ac24bd72a9b2darylm       */
1434710c53dcad1ebf3755f3efb9e80ac24bd72a9b2darylm
1444710c53dcad1ebf3755f3efb9e80ac24bd72a9b2darylm     /* Implemented elsewhere:
1454710c53dcad1ebf3755f3efb9e80ac24bd72a9b2darylm
1464710c53dcad1ebf3755f3efb9e80ac24bd72a9b2darylm     int PyObject_HasAttrString(PyObject *o, char *attr_name);
1474710c53dcad1ebf3755f3efb9e80ac24bd72a9b2darylm
1484710c53dcad1ebf3755f3efb9e80ac24bd72a9b2darylm     Returns 1 if o has the attribute attr_name, and 0 otherwise.
1494710c53dcad1ebf3755f3efb9e80ac24bd72a9b2darylm     This is equivalent to the Python expression:
1504710c53dcad1ebf3755f3efb9e80ac24bd72a9b2darylm     hasattr(o,attr_name).
1514710c53dcad1ebf3755f3efb9e80ac24bd72a9b2darylm
1524710c53dcad1ebf3755f3efb9e80ac24bd72a9b2darylm     This function always succeeds.
1534710c53dcad1ebf3755f3efb9e80ac24bd72a9b2darylm
1544710c53dcad1ebf3755f3efb9e80ac24bd72a9b2darylm       */
1554710c53dcad1ebf3755f3efb9e80ac24bd72a9b2darylm
1564710c53dcad1ebf3755f3efb9e80ac24bd72a9b2darylm     /* Implemented elsewhere:
1574710c53dcad1ebf3755f3efb9e80ac24bd72a9b2darylm
1584710c53dcad1ebf3755f3efb9e80ac24bd72a9b2darylm     PyObject* PyObject_GetAttrString(PyObject *o, char *attr_name);
1594710c53dcad1ebf3755f3efb9e80ac24bd72a9b2darylm
1604710c53dcad1ebf3755f3efb9e80ac24bd72a9b2darylm     Retrieve an attributed named attr_name form object o.
1614710c53dcad1ebf3755f3efb9e80ac24bd72a9b2darylm     Returns the attribute value on success, or NULL on failure.
1624710c53dcad1ebf3755f3efb9e80ac24bd72a9b2darylm     This is the equivalent of the Python expression: o.attr_name.
1634710c53dcad1ebf3755f3efb9e80ac24bd72a9b2darylm
1644710c53dcad1ebf3755f3efb9e80ac24bd72a9b2darylm       */
1654710c53dcad1ebf3755f3efb9e80ac24bd72a9b2darylm
1664710c53dcad1ebf3755f3efb9e80ac24bd72a9b2darylm     /* Implemented elsewhere:
1674710c53dcad1ebf3755f3efb9e80ac24bd72a9b2darylm
1684710c53dcad1ebf3755f3efb9e80ac24bd72a9b2darylm     int PyObject_HasAttr(PyObject *o, PyObject *attr_name);
1694710c53dcad1ebf3755f3efb9e80ac24bd72a9b2darylm
1704710c53dcad1ebf3755f3efb9e80ac24bd72a9b2darylm     Returns 1 if o has the attribute attr_name, and 0 otherwise.
1714710c53dcad1ebf3755f3efb9e80ac24bd72a9b2darylm     This is equivalent to the Python expression:
1724710c53dcad1ebf3755f3efb9e80ac24bd72a9b2darylm     hasattr(o,attr_name).
1734710c53dcad1ebf3755f3efb9e80ac24bd72a9b2darylm
1744710c53dcad1ebf3755f3efb9e80ac24bd72a9b2darylm     This function always succeeds.
1754710c53dcad1ebf3755f3efb9e80ac24bd72a9b2darylm
1764710c53dcad1ebf3755f3efb9e80ac24bd72a9b2darylm       */
1774710c53dcad1ebf3755f3efb9e80ac24bd72a9b2darylm
1784710c53dcad1ebf3755f3efb9e80ac24bd72a9b2darylm     /* Implemented elsewhere:
1794710c53dcad1ebf3755f3efb9e80ac24bd72a9b2darylm
1804710c53dcad1ebf3755f3efb9e80ac24bd72a9b2darylm     PyObject* PyObject_GetAttr(PyObject *o, PyObject *attr_name);
1814710c53dcad1ebf3755f3efb9e80ac24bd72a9b2darylm
1824710c53dcad1ebf3755f3efb9e80ac24bd72a9b2darylm     Retrieve an attributed named attr_name form object o.
1834710c53dcad1ebf3755f3efb9e80ac24bd72a9b2darylm     Returns the attribute value on success, or NULL on failure.
1844710c53dcad1ebf3755f3efb9e80ac24bd72a9b2darylm     This is the equivalent of the Python expression: o.attr_name.
1854710c53dcad1ebf3755f3efb9e80ac24bd72a9b2darylm
1864710c53dcad1ebf3755f3efb9e80ac24bd72a9b2darylm       */
1874710c53dcad1ebf3755f3efb9e80ac24bd72a9b2darylm
1884710c53dcad1ebf3755f3efb9e80ac24bd72a9b2darylm
1894710c53dcad1ebf3755f3efb9e80ac24bd72a9b2darylm     /* Implemented elsewhere:
1904710c53dcad1ebf3755f3efb9e80ac24bd72a9b2darylm
1914710c53dcad1ebf3755f3efb9e80ac24bd72a9b2darylm     int PyObject_SetAttrString(PyObject *o, char *attr_name, PyObject *v);
1924710c53dcad1ebf3755f3efb9e80ac24bd72a9b2darylm
1934710c53dcad1ebf3755f3efb9e80ac24bd72a9b2darylm     Set the value of the attribute named attr_name, for object o,
1944710c53dcad1ebf3755f3efb9e80ac24bd72a9b2darylm     to the value, v. Returns -1 on failure.  This is
1954710c53dcad1ebf3755f3efb9e80ac24bd72a9b2darylm     the equivalent of the Python statement: o.attr_name=v.
1964710c53dcad1ebf3755f3efb9e80ac24bd72a9b2darylm
1974710c53dcad1ebf3755f3efb9e80ac24bd72a9b2darylm       */
1984710c53dcad1ebf3755f3efb9e80ac24bd72a9b2darylm
1994710c53dcad1ebf3755f3efb9e80ac24bd72a9b2darylm     /* Implemented elsewhere:
2004710c53dcad1ebf3755f3efb9e80ac24bd72a9b2darylm
2014710c53dcad1ebf3755f3efb9e80ac24bd72a9b2darylm     int PyObject_SetAttr(PyObject *o, PyObject *attr_name, PyObject *v);
2024710c53dcad1ebf3755f3efb9e80ac24bd72a9b2darylm
2034710c53dcad1ebf3755f3efb9e80ac24bd72a9b2darylm     Set the value of the attribute named attr_name, for object o,
2044710c53dcad1ebf3755f3efb9e80ac24bd72a9b2darylm     to the value, v. Returns -1 on failure.  This is
2054710c53dcad1ebf3755f3efb9e80ac24bd72a9b2darylm     the equivalent of the Python statement: o.attr_name=v.
2064710c53dcad1ebf3755f3efb9e80ac24bd72a9b2darylm
2074710c53dcad1ebf3755f3efb9e80ac24bd72a9b2darylm       */
2084710c53dcad1ebf3755f3efb9e80ac24bd72a9b2darylm
2094710c53dcad1ebf3755f3efb9e80ac24bd72a9b2darylm     /* implemented as a macro:
2104710c53dcad1ebf3755f3efb9e80ac24bd72a9b2darylm
2114710c53dcad1ebf3755f3efb9e80ac24bd72a9b2darylm     int PyObject_DelAttrString(PyObject *o, char *attr_name);
2124710c53dcad1ebf3755f3efb9e80ac24bd72a9b2darylm
2134710c53dcad1ebf3755f3efb9e80ac24bd72a9b2darylm     Delete attribute named attr_name, for object o. Returns
2144710c53dcad1ebf3755f3efb9e80ac24bd72a9b2darylm     -1 on failure.  This is the equivalent of the Python
2154710c53dcad1ebf3755f3efb9e80ac24bd72a9b2darylm     statement: del o.attr_name.
2164710c53dcad1ebf3755f3efb9e80ac24bd72a9b2darylm
2174710c53dcad1ebf3755f3efb9e80ac24bd72a9b2darylm       */
2184710c53dcad1ebf3755f3efb9e80ac24bd72a9b2darylm#define  PyObject_DelAttrString(O,A) PyObject_SetAttrString((O),(A),NULL)
2194710c53dcad1ebf3755f3efb9e80ac24bd72a9b2darylm
2204710c53dcad1ebf3755f3efb9e80ac24bd72a9b2darylm     /* implemented as a macro:
2214710c53dcad1ebf3755f3efb9e80ac24bd72a9b2darylm
2224710c53dcad1ebf3755f3efb9e80ac24bd72a9b2darylm     int PyObject_DelAttr(PyObject *o, PyObject *attr_name);
2234710c53dcad1ebf3755f3efb9e80ac24bd72a9b2darylm
2244710c53dcad1ebf3755f3efb9e80ac24bd72a9b2darylm     Delete attribute named attr_name, for object o. Returns -1
2254710c53dcad1ebf3755f3efb9e80ac24bd72a9b2darylm     on failure.  This is the equivalent of the Python
2264710c53dcad1ebf3755f3efb9e80ac24bd72a9b2darylm     statement: del o.attr_name.
2274710c53dcad1ebf3755f3efb9e80ac24bd72a9b2darylm
2284710c53dcad1ebf3755f3efb9e80ac24bd72a9b2darylm       */
2294710c53dcad1ebf3755f3efb9e80ac24bd72a9b2darylm#define  PyObject_DelAttr(O,A) PyObject_SetAttr((O),(A),NULL)
2304710c53dcad1ebf3755f3efb9e80ac24bd72a9b2darylm
2314710c53dcad1ebf3755f3efb9e80ac24bd72a9b2darylm     PyAPI_FUNC(int) PyObject_Cmp(PyObject *o1, PyObject *o2, int *result);
2324710c53dcad1ebf3755f3efb9e80ac24bd72a9b2darylm
2334710c53dcad1ebf3755f3efb9e80ac24bd72a9b2darylm       /*
2344710c53dcad1ebf3755f3efb9e80ac24bd72a9b2darylm     Compare the values of o1 and o2 using a routine provided by
2354710c53dcad1ebf3755f3efb9e80ac24bd72a9b2darylm     o1, if one exists, otherwise with a routine provided by o2.
2364710c53dcad1ebf3755f3efb9e80ac24bd72a9b2darylm     The result of the comparison is returned in result.  Returns
2374710c53dcad1ebf3755f3efb9e80ac24bd72a9b2darylm     -1 on failure.  This is the equivalent of the Python
2384710c53dcad1ebf3755f3efb9e80ac24bd72a9b2darylm     statement: result=cmp(o1,o2).
2394710c53dcad1ebf3755f3efb9e80ac24bd72a9b2darylm
2404710c53dcad1ebf3755f3efb9e80ac24bd72a9b2darylm       */
2414710c53dcad1ebf3755f3efb9e80ac24bd72a9b2darylm
2424710c53dcad1ebf3755f3efb9e80ac24bd72a9b2darylm     /* Implemented elsewhere:
2434710c53dcad1ebf3755f3efb9e80ac24bd72a9b2darylm
2444710c53dcad1ebf3755f3efb9e80ac24bd72a9b2darylm     int PyObject_Compare(PyObject *o1, PyObject *o2);
2454710c53dcad1ebf3755f3efb9e80ac24bd72a9b2darylm
2464710c53dcad1ebf3755f3efb9e80ac24bd72a9b2darylm     Compare the values of o1 and o2 using a routine provided by
2474710c53dcad1ebf3755f3efb9e80ac24bd72a9b2darylm     o1, if one exists, otherwise with a routine provided by o2.
2484710c53dcad1ebf3755f3efb9e80ac24bd72a9b2darylm     Returns the result of the comparison on success.  On error,
2494710c53dcad1ebf3755f3efb9e80ac24bd72a9b2darylm     the value returned is undefined. This is equivalent to the
2504710c53dcad1ebf3755f3efb9e80ac24bd72a9b2darylm     Python expression: cmp(o1,o2).
2514710c53dcad1ebf3755f3efb9e80ac24bd72a9b2darylm
2524710c53dcad1ebf3755f3efb9e80ac24bd72a9b2darylm       */
2534710c53dcad1ebf3755f3efb9e80ac24bd72a9b2darylm
2544710c53dcad1ebf3755f3efb9e80ac24bd72a9b2darylm     /* Implemented elsewhere:
2554710c53dcad1ebf3755f3efb9e80ac24bd72a9b2darylm
2564710c53dcad1ebf3755f3efb9e80ac24bd72a9b2darylm     PyObject *PyObject_Repr(PyObject *o);
2574710c53dcad1ebf3755f3efb9e80ac24bd72a9b2darylm
2584710c53dcad1ebf3755f3efb9e80ac24bd72a9b2darylm     Compute the string representation of object, o.  Returns the
2594710c53dcad1ebf3755f3efb9e80ac24bd72a9b2darylm     string representation on success, NULL on failure.  This is
2604710c53dcad1ebf3755f3efb9e80ac24bd72a9b2darylm     the equivalent of the Python expression: repr(o).
2614710c53dcad1ebf3755f3efb9e80ac24bd72a9b2darylm
2624710c53dcad1ebf3755f3efb9e80ac24bd72a9b2darylm     Called by the repr() built-in function and by reverse quotes.
2634710c53dcad1ebf3755f3efb9e80ac24bd72a9b2darylm
2644710c53dcad1ebf3755f3efb9e80ac24bd72a9b2darylm       */
2654710c53dcad1ebf3755f3efb9e80ac24bd72a9b2darylm
2664710c53dcad1ebf3755f3efb9e80ac24bd72a9b2darylm     /* Implemented elsewhere:
2674710c53dcad1ebf3755f3efb9e80ac24bd72a9b2darylm
2684710c53dcad1ebf3755f3efb9e80ac24bd72a9b2darylm     PyObject *PyObject_Str(PyObject *o);
2694710c53dcad1ebf3755f3efb9e80ac24bd72a9b2darylm
2704710c53dcad1ebf3755f3efb9e80ac24bd72a9b2darylm     Compute the string representation of object, o.  Returns the
2714710c53dcad1ebf3755f3efb9e80ac24bd72a9b2darylm     string representation on success, NULL on failure.  This is
2724710c53dcad1ebf3755f3efb9e80ac24bd72a9b2darylm     the equivalent of the Python expression: str(o).)
2734710c53dcad1ebf3755f3efb9e80ac24bd72a9b2darylm
2744710c53dcad1ebf3755f3efb9e80ac24bd72a9b2darylm     Called by the str() built-in function and by the print
2754710c53dcad1ebf3755f3efb9e80ac24bd72a9b2darylm     statement.
2764710c53dcad1ebf3755f3efb9e80ac24bd72a9b2darylm
2774710c53dcad1ebf3755f3efb9e80ac24bd72a9b2darylm       */
2784710c53dcad1ebf3755f3efb9e80ac24bd72a9b2darylm
2794710c53dcad1ebf3755f3efb9e80ac24bd72a9b2darylm     /* Implemented elsewhere:
2804710c53dcad1ebf3755f3efb9e80ac24bd72a9b2darylm
2814710c53dcad1ebf3755f3efb9e80ac24bd72a9b2darylm     PyObject *PyObject_Unicode(PyObject *o);
2824710c53dcad1ebf3755f3efb9e80ac24bd72a9b2darylm
2834710c53dcad1ebf3755f3efb9e80ac24bd72a9b2darylm     Compute the unicode representation of object, o.  Returns the
2844710c53dcad1ebf3755f3efb9e80ac24bd72a9b2darylm     unicode representation on success, NULL on failure.  This is
2854710c53dcad1ebf3755f3efb9e80ac24bd72a9b2darylm     the equivalent of the Python expression: unistr(o).)
2864710c53dcad1ebf3755f3efb9e80ac24bd72a9b2darylm
2874710c53dcad1ebf3755f3efb9e80ac24bd72a9b2darylm     Called by the unistr() built-in function.
2884710c53dcad1ebf3755f3efb9e80ac24bd72a9b2darylm
2894710c53dcad1ebf3755f3efb9e80ac24bd72a9b2darylm       */
2904710c53dcad1ebf3755f3efb9e80ac24bd72a9b2darylm
2914710c53dcad1ebf3755f3efb9e80ac24bd72a9b2darylm       /* Declared elsewhere
2924710c53dcad1ebf3755f3efb9e80ac24bd72a9b2darylm
2934710c53dcad1ebf3755f3efb9e80ac24bd72a9b2darylm     PyAPI_FUNC(int) PyCallable_Check(PyObject *o);
2944710c53dcad1ebf3755f3efb9e80ac24bd72a9b2darylm
2954710c53dcad1ebf3755f3efb9e80ac24bd72a9b2darylm     Determine if the object, o, is callable.  Return 1 if the
2964710c53dcad1ebf3755f3efb9e80ac24bd72a9b2darylm     object is callable and 0 otherwise.
2974710c53dcad1ebf3755f3efb9e80ac24bd72a9b2darylm
2984710c53dcad1ebf3755f3efb9e80ac24bd72a9b2darylm     This function always succeeds.
2994710c53dcad1ebf3755f3efb9e80ac24bd72a9b2darylm
3004710c53dcad1ebf3755f3efb9e80ac24bd72a9b2darylm       */
3014710c53dcad1ebf3755f3efb9e80ac24bd72a9b2darylm
3024710c53dcad1ebf3755f3efb9e80ac24bd72a9b2darylm
3034710c53dcad1ebf3755f3efb9e80ac24bd72a9b2darylm
3044710c53dcad1ebf3755f3efb9e80ac24bd72a9b2darylm     PyAPI_FUNC(PyObject *) PyObject_Call(PyObject *callable_object,
3054710c53dcad1ebf3755f3efb9e80ac24bd72a9b2darylm                                         PyObject *args, PyObject *kw);
3064710c53dcad1ebf3755f3efb9e80ac24bd72a9b2darylm
3074710c53dcad1ebf3755f3efb9e80ac24bd72a9b2darylm       /*
3084710c53dcad1ebf3755f3efb9e80ac24bd72a9b2darylm     Call a callable Python object, callable_object, with
3094710c53dcad1ebf3755f3efb9e80ac24bd72a9b2darylm     arguments and keywords arguments.  The 'args' argument can not be
3104710c53dcad1ebf3755f3efb9e80ac24bd72a9b2darylm     NULL, but the 'kw' argument can be NULL.
3114710c53dcad1ebf3755f3efb9e80ac24bd72a9b2darylm
3124710c53dcad1ebf3755f3efb9e80ac24bd72a9b2darylm       */
3134710c53dcad1ebf3755f3efb9e80ac24bd72a9b2darylm
3144710c53dcad1ebf3755f3efb9e80ac24bd72a9b2darylm     PyAPI_FUNC(PyObject *) PyObject_CallObject(PyObject *callable_object,
3154710c53dcad1ebf3755f3efb9e80ac24bd72a9b2darylm                                               PyObject *args);
3164710c53dcad1ebf3755f3efb9e80ac24bd72a9b2darylm
3174710c53dcad1ebf3755f3efb9e80ac24bd72a9b2darylm       /*
3184710c53dcad1ebf3755f3efb9e80ac24bd72a9b2darylm     Call a callable Python object, callable_object, with
3194710c53dcad1ebf3755f3efb9e80ac24bd72a9b2darylm     arguments given by the tuple, args.  If no arguments are
3204710c53dcad1ebf3755f3efb9e80ac24bd72a9b2darylm     needed, then args may be NULL.  Returns the result of the
3214710c53dcad1ebf3755f3efb9e80ac24bd72a9b2darylm     call on success, or NULL on failure.  This is the equivalent
3224710c53dcad1ebf3755f3efb9e80ac24bd72a9b2darylm     of the Python expression: apply(o,args).
3234710c53dcad1ebf3755f3efb9e80ac24bd72a9b2darylm
3244710c53dcad1ebf3755f3efb9e80ac24bd72a9b2darylm       */
3254710c53dcad1ebf3755f3efb9e80ac24bd72a9b2darylm
3264710c53dcad1ebf3755f3efb9e80ac24bd72a9b2darylm     PyAPI_FUNC(PyObject *) PyObject_CallFunction(PyObject *callable_object,
3274710c53dcad1ebf3755f3efb9e80ac24bd72a9b2darylm                                                 char *format, ...);
3284710c53dcad1ebf3755f3efb9e80ac24bd72a9b2darylm
3294710c53dcad1ebf3755f3efb9e80ac24bd72a9b2darylm       /*
3304710c53dcad1ebf3755f3efb9e80ac24bd72a9b2darylm     Call a callable Python object, callable_object, with a
3314710c53dcad1ebf3755f3efb9e80ac24bd72a9b2darylm     variable number of C arguments. The C arguments are described
3324710c53dcad1ebf3755f3efb9e80ac24bd72a9b2darylm     using a mkvalue-style format string. The format may be NULL,
3334710c53dcad1ebf3755f3efb9e80ac24bd72a9b2darylm     indicating that no arguments are provided.  Returns the
3344710c53dcad1ebf3755f3efb9e80ac24bd72a9b2darylm     result of the call on success, or NULL on failure.  This is
3354710c53dcad1ebf3755f3efb9e80ac24bd72a9b2darylm     the equivalent of the Python expression: apply(o,args).
3364710c53dcad1ebf3755f3efb9e80ac24bd72a9b2darylm
3374710c53dcad1ebf3755f3efb9e80ac24bd72a9b2darylm       */
3384710c53dcad1ebf3755f3efb9e80ac24bd72a9b2darylm
3394710c53dcad1ebf3755f3efb9e80ac24bd72a9b2darylm
3404710c53dcad1ebf3755f3efb9e80ac24bd72a9b2darylm     PyAPI_FUNC(PyObject *) PyObject_CallMethod(PyObject *o, char *m,
3414710c53dcad1ebf3755f3efb9e80ac24bd72a9b2darylm                                               char *format, ...);
3424710c53dcad1ebf3755f3efb9e80ac24bd72a9b2darylm
3434710c53dcad1ebf3755f3efb9e80ac24bd72a9b2darylm       /*
3444710c53dcad1ebf3755f3efb9e80ac24bd72a9b2darylm     Call the method named m of object o with a variable number of
3454710c53dcad1ebf3755f3efb9e80ac24bd72a9b2darylm     C arguments.  The C arguments are described by a mkvalue
3464710c53dcad1ebf3755f3efb9e80ac24bd72a9b2darylm     format string.  The format may be NULL, indicating that no
3474710c53dcad1ebf3755f3efb9e80ac24bd72a9b2darylm     arguments are provided. Returns the result of the call on
3484710c53dcad1ebf3755f3efb9e80ac24bd72a9b2darylm     success, or NULL on failure.  This is the equivalent of the
3494710c53dcad1ebf3755f3efb9e80ac24bd72a9b2darylm     Python expression: o.method(args).
3504710c53dcad1ebf3755f3efb9e80ac24bd72a9b2darylm       */
3514710c53dcad1ebf3755f3efb9e80ac24bd72a9b2darylm
3524710c53dcad1ebf3755f3efb9e80ac24bd72a9b2darylm     PyAPI_FUNC(PyObject *) _PyObject_CallFunction_SizeT(PyObject *callable,
3534710c53dcad1ebf3755f3efb9e80ac24bd72a9b2darylm                                                         char *format, ...);
3544710c53dcad1ebf3755f3efb9e80ac24bd72a9b2darylm     PyAPI_FUNC(PyObject *) _PyObject_CallMethod_SizeT(PyObject *o,
3554710c53dcad1ebf3755f3efb9e80ac24bd72a9b2darylm                                                       char *name,
3564710c53dcad1ebf3755f3efb9e80ac24bd72a9b2darylm                                                       char *format, ...);
3574710c53dcad1ebf3755f3efb9e80ac24bd72a9b2darylm
3584710c53dcad1ebf3755f3efb9e80ac24bd72a9b2darylm     PyAPI_FUNC(PyObject *) PyObject_CallFunctionObjArgs(PyObject *callable,
3594710c53dcad1ebf3755f3efb9e80ac24bd72a9b2darylm                                                        ...);
3604710c53dcad1ebf3755f3efb9e80ac24bd72a9b2darylm
3614710c53dcad1ebf3755f3efb9e80ac24bd72a9b2darylm       /*
3624710c53dcad1ebf3755f3efb9e80ac24bd72a9b2darylm     Call a callable Python object, callable_object, with a
3634710c53dcad1ebf3755f3efb9e80ac24bd72a9b2darylm     variable number of C arguments.  The C arguments are provided
3644710c53dcad1ebf3755f3efb9e80ac24bd72a9b2darylm     as PyObject * values, terminated by a NULL.  Returns the
3654710c53dcad1ebf3755f3efb9e80ac24bd72a9b2darylm     result of the call on success, or NULL on failure.  This is
3664710c53dcad1ebf3755f3efb9e80ac24bd72a9b2darylm     the equivalent of the Python expression: apply(o,args).
3674710c53dcad1ebf3755f3efb9e80ac24bd72a9b2darylm       */
3684710c53dcad1ebf3755f3efb9e80ac24bd72a9b2darylm
3694710c53dcad1ebf3755f3efb9e80ac24bd72a9b2darylm
3704710c53dcad1ebf3755f3efb9e80ac24bd72a9b2darylm     PyAPI_FUNC(PyObject *) PyObject_CallMethodObjArgs(PyObject *o,
3714710c53dcad1ebf3755f3efb9e80ac24bd72a9b2darylm                                                      PyObject *m, ...);
3724710c53dcad1ebf3755f3efb9e80ac24bd72a9b2darylm
3734710c53dcad1ebf3755f3efb9e80ac24bd72a9b2darylm       /*
3744710c53dcad1ebf3755f3efb9e80ac24bd72a9b2darylm     Call the method named m of object o with a variable number of
3754710c53dcad1ebf3755f3efb9e80ac24bd72a9b2darylm     C arguments.  The C arguments are provided as PyObject *
3764710c53dcad1ebf3755f3efb9e80ac24bd72a9b2darylm     values, terminated by NULL.  Returns the result of the call
3774710c53dcad1ebf3755f3efb9e80ac24bd72a9b2darylm     on success, or NULL on failure.  This is the equivalent of
3784710c53dcad1ebf3755f3efb9e80ac24bd72a9b2darylm     the Python expression: o.method(args).
3794710c53dcad1ebf3755f3efb9e80ac24bd72a9b2darylm       */
3804710c53dcad1ebf3755f3efb9e80ac24bd72a9b2darylm
3814710c53dcad1ebf3755f3efb9e80ac24bd72a9b2darylm
3824710c53dcad1ebf3755f3efb9e80ac24bd72a9b2darylm     /* Implemented elsewhere:
3834710c53dcad1ebf3755f3efb9e80ac24bd72a9b2darylm
3844710c53dcad1ebf3755f3efb9e80ac24bd72a9b2darylm     long PyObject_Hash(PyObject *o);
3854710c53dcad1ebf3755f3efb9e80ac24bd72a9b2darylm
3864710c53dcad1ebf3755f3efb9e80ac24bd72a9b2darylm     Compute and return the hash, hash_value, of an object, o.  On
3874710c53dcad1ebf3755f3efb9e80ac24bd72a9b2darylm     failure, return -1.  This is the equivalent of the Python
3884710c53dcad1ebf3755f3efb9e80ac24bd72a9b2darylm     expression: hash(o).
3894710c53dcad1ebf3755f3efb9e80ac24bd72a9b2darylm
3904710c53dcad1ebf3755f3efb9e80ac24bd72a9b2darylm       */
3914710c53dcad1ebf3755f3efb9e80ac24bd72a9b2darylm
3924710c53dcad1ebf3755f3efb9e80ac24bd72a9b2darylm
3934710c53dcad1ebf3755f3efb9e80ac24bd72a9b2darylm     /* Implemented elsewhere:
3944710c53dcad1ebf3755f3efb9e80ac24bd72a9b2darylm
3954710c53dcad1ebf3755f3efb9e80ac24bd72a9b2darylm     int PyObject_IsTrue(PyObject *o);
3964710c53dcad1ebf3755f3efb9e80ac24bd72a9b2darylm
3974710c53dcad1ebf3755f3efb9e80ac24bd72a9b2darylm     Returns 1 if the object, o, is considered to be true, 0 if o is
3984710c53dcad1ebf3755f3efb9e80ac24bd72a9b2darylm     considered to be false and -1 on failure. This is equivalent to the
3994710c53dcad1ebf3755f3efb9e80ac24bd72a9b2darylm     Python expression: not not o
4004710c53dcad1ebf3755f3efb9e80ac24bd72a9b2darylm
4014710c53dcad1ebf3755f3efb9e80ac24bd72a9b2darylm       */
4024710c53dcad1ebf3755f3efb9e80ac24bd72a9b2darylm
4034710c53dcad1ebf3755f3efb9e80ac24bd72a9b2darylm     /* Implemented elsewhere:
4044710c53dcad1ebf3755f3efb9e80ac24bd72a9b2darylm
4054710c53dcad1ebf3755f3efb9e80ac24bd72a9b2darylm     int PyObject_Not(PyObject *o);
4064710c53dcad1ebf3755f3efb9e80ac24bd72a9b2darylm
4074710c53dcad1ebf3755f3efb9e80ac24bd72a9b2darylm     Returns 0 if the object, o, is considered to be true, 1 if o is
4084710c53dcad1ebf3755f3efb9e80ac24bd72a9b2darylm     considered to be false and -1 on failure. This is equivalent to the
4094710c53dcad1ebf3755f3efb9e80ac24bd72a9b2darylm     Python expression: not o
4104710c53dcad1ebf3755f3efb9e80ac24bd72a9b2darylm
4114710c53dcad1ebf3755f3efb9e80ac24bd72a9b2darylm       */
4124710c53dcad1ebf3755f3efb9e80ac24bd72a9b2darylm
4134710c53dcad1ebf3755f3efb9e80ac24bd72a9b2darylm     PyAPI_FUNC(PyObject *) PyObject_Type(PyObject *o);
4144710c53dcad1ebf3755f3efb9e80ac24bd72a9b2darylm
4154710c53dcad1ebf3755f3efb9e80ac24bd72a9b2darylm       /*
4164710c53dcad1ebf3755f3efb9e80ac24bd72a9b2darylm     On success, returns a type object corresponding to the object
4174710c53dcad1ebf3755f3efb9e80ac24bd72a9b2darylm     type of object o. On failure, returns NULL.  This is
4184710c53dcad1ebf3755f3efb9e80ac24bd72a9b2darylm     equivalent to the Python expression: type(o).
4194710c53dcad1ebf3755f3efb9e80ac24bd72a9b2darylm       */
4204710c53dcad1ebf3755f3efb9e80ac24bd72a9b2darylm
4214710c53dcad1ebf3755f3efb9e80ac24bd72a9b2darylm     PyAPI_FUNC(Py_ssize_t) PyObject_Size(PyObject *o);
4224710c53dcad1ebf3755f3efb9e80ac24bd72a9b2darylm
4234710c53dcad1ebf3755f3efb9e80ac24bd72a9b2darylm       /*
4244710c53dcad1ebf3755f3efb9e80ac24bd72a9b2darylm     Return the size of object o.  If the object, o, provides
4254710c53dcad1ebf3755f3efb9e80ac24bd72a9b2darylm     both sequence and mapping protocols, the sequence size is
4264710c53dcad1ebf3755f3efb9e80ac24bd72a9b2darylm     returned. On error, -1 is returned.  This is the equivalent
4274710c53dcad1ebf3755f3efb9e80ac24bd72a9b2darylm     to the Python expression: len(o).
4284710c53dcad1ebf3755f3efb9e80ac24bd72a9b2darylm
4294710c53dcad1ebf3755f3efb9e80ac24bd72a9b2darylm       */
4304710c53dcad1ebf3755f3efb9e80ac24bd72a9b2darylm
4314710c53dcad1ebf3755f3efb9e80ac24bd72a9b2darylm       /* For DLL compatibility */
4324710c53dcad1ebf3755f3efb9e80ac24bd72a9b2darylm#undef PyObject_Length
4334710c53dcad1ebf3755f3efb9e80ac24bd72a9b2darylm     PyAPI_FUNC(Py_ssize_t) PyObject_Length(PyObject *o);
4344710c53dcad1ebf3755f3efb9e80ac24bd72a9b2darylm#define PyObject_Length PyObject_Size
4354710c53dcad1ebf3755f3efb9e80ac24bd72a9b2darylm
4364710c53dcad1ebf3755f3efb9e80ac24bd72a9b2darylm     PyAPI_FUNC(Py_ssize_t) _PyObject_LengthHint(PyObject *o, Py_ssize_t);
4374710c53dcad1ebf3755f3efb9e80ac24bd72a9b2darylm
4384710c53dcad1ebf3755f3efb9e80ac24bd72a9b2darylm       /*
4394710c53dcad1ebf3755f3efb9e80ac24bd72a9b2darylm     Guess the size of object o using len(o) or o.__length_hint__().
4404710c53dcad1ebf3755f3efb9e80ac24bd72a9b2darylm     If neither of those return a non-negative value, then return the
4414710c53dcad1ebf3755f3efb9e80ac24bd72a9b2darylm     default value.  If one of the calls fails, this function returns -1.
4424710c53dcad1ebf3755f3efb9e80ac24bd72a9b2darylm       */
4434710c53dcad1ebf3755f3efb9e80ac24bd72a9b2darylm
4444710c53dcad1ebf3755f3efb9e80ac24bd72a9b2darylm     PyAPI_FUNC(PyObject *) PyObject_GetItem(PyObject *o, PyObject *key);
4454710c53dcad1ebf3755f3efb9e80ac24bd72a9b2darylm
4464710c53dcad1ebf3755f3efb9e80ac24bd72a9b2darylm       /*
4474710c53dcad1ebf3755f3efb9e80ac24bd72a9b2darylm     Return element of o corresponding to the object, key, or NULL
4484710c53dcad1ebf3755f3efb9e80ac24bd72a9b2darylm     on failure. This is the equivalent of the Python expression:
4494710c53dcad1ebf3755f3efb9e80ac24bd72a9b2darylm     o[key].
4504710c53dcad1ebf3755f3efb9e80ac24bd72a9b2darylm
4514710c53dcad1ebf3755f3efb9e80ac24bd72a9b2darylm       */
4524710c53dcad1ebf3755f3efb9e80ac24bd72a9b2darylm
4534710c53dcad1ebf3755f3efb9e80ac24bd72a9b2darylm     PyAPI_FUNC(int) PyObject_SetItem(PyObject *o, PyObject *key, PyObject *v);
4544710c53dcad1ebf3755f3efb9e80ac24bd72a9b2darylm
4554710c53dcad1ebf3755f3efb9e80ac24bd72a9b2darylm       /*
4564710c53dcad1ebf3755f3efb9e80ac24bd72a9b2darylm     Map the object, key, to the value, v.  Returns
4574710c53dcad1ebf3755f3efb9e80ac24bd72a9b2darylm     -1 on failure.  This is the equivalent of the Python
4584710c53dcad1ebf3755f3efb9e80ac24bd72a9b2darylm     statement: o[key]=v.
4594710c53dcad1ebf3755f3efb9e80ac24bd72a9b2darylm       */
4604710c53dcad1ebf3755f3efb9e80ac24bd72a9b2darylm
4614710c53dcad1ebf3755f3efb9e80ac24bd72a9b2darylm     PyAPI_FUNC(int) PyObject_DelItemString(PyObject *o, char *key);
4624710c53dcad1ebf3755f3efb9e80ac24bd72a9b2darylm
4634710c53dcad1ebf3755f3efb9e80ac24bd72a9b2darylm       /*
4644710c53dcad1ebf3755f3efb9e80ac24bd72a9b2darylm     Remove the mapping for object, key, from the object *o.
4654710c53dcad1ebf3755f3efb9e80ac24bd72a9b2darylm     Returns -1 on failure.  This is equivalent to
4664710c53dcad1ebf3755f3efb9e80ac24bd72a9b2darylm     the Python statement: del o[key].
4674710c53dcad1ebf3755f3efb9e80ac24bd72a9b2darylm       */
4684710c53dcad1ebf3755f3efb9e80ac24bd72a9b2darylm
4694710c53dcad1ebf3755f3efb9e80ac24bd72a9b2darylm     PyAPI_FUNC(int) PyObject_DelItem(PyObject *o, PyObject *key);
4704710c53dcad1ebf3755f3efb9e80ac24bd72a9b2darylm
4714710c53dcad1ebf3755f3efb9e80ac24bd72a9b2darylm       /*
4724710c53dcad1ebf3755f3efb9e80ac24bd72a9b2darylm     Delete the mapping for key from *o.  Returns -1 on failure.
4734710c53dcad1ebf3755f3efb9e80ac24bd72a9b2darylm     This is the equivalent of the Python statement: del o[key].
4744710c53dcad1ebf3755f3efb9e80ac24bd72a9b2darylm       */
4754710c53dcad1ebf3755f3efb9e80ac24bd72a9b2darylm
4764710c53dcad1ebf3755f3efb9e80ac24bd72a9b2darylm     PyAPI_FUNC(int) PyObject_AsCharBuffer(PyObject *obj,
4774710c53dcad1ebf3755f3efb9e80ac24bd72a9b2darylm                                          const char **buffer,
4784710c53dcad1ebf3755f3efb9e80ac24bd72a9b2darylm                                          Py_ssize_t *buffer_len);
4794710c53dcad1ebf3755f3efb9e80ac24bd72a9b2darylm
4804710c53dcad1ebf3755f3efb9e80ac24bd72a9b2darylm       /*
4814710c53dcad1ebf3755f3efb9e80ac24bd72a9b2darylm      Takes an arbitrary object which must support the (character,
4824710c53dcad1ebf3755f3efb9e80ac24bd72a9b2darylm      single segment) buffer interface and returns a pointer to a
4834710c53dcad1ebf3755f3efb9e80ac24bd72a9b2darylm      read-only memory location useable as character based input
4844710c53dcad1ebf3755f3efb9e80ac24bd72a9b2darylm      for subsequent processing.
4854710c53dcad1ebf3755f3efb9e80ac24bd72a9b2darylm
4864710c53dcad1ebf3755f3efb9e80ac24bd72a9b2darylm      0 is returned on success.  buffer and buffer_len are only
4874710c53dcad1ebf3755f3efb9e80ac24bd72a9b2darylm      set in case no error occurs. Otherwise, -1 is returned and
4884710c53dcad1ebf3755f3efb9e80ac24bd72a9b2darylm      an exception set.
4894710c53dcad1ebf3755f3efb9e80ac24bd72a9b2darylm
4904710c53dcad1ebf3755f3efb9e80ac24bd72a9b2darylm       */
4914710c53dcad1ebf3755f3efb9e80ac24bd72a9b2darylm
4924710c53dcad1ebf3755f3efb9e80ac24bd72a9b2darylm     PyAPI_FUNC(int) PyObject_CheckReadBuffer(PyObject *obj);
4934710c53dcad1ebf3755f3efb9e80ac24bd72a9b2darylm
4944710c53dcad1ebf3755f3efb9e80ac24bd72a9b2darylm      /*
4954710c53dcad1ebf3755f3efb9e80ac24bd72a9b2darylm      Checks whether an arbitrary object supports the (character,
4964710c53dcad1ebf3755f3efb9e80ac24bd72a9b2darylm      single segment) buffer interface.  Returns 1 on success, 0
4974710c53dcad1ebf3755f3efb9e80ac24bd72a9b2darylm      on failure.
4984710c53dcad1ebf3755f3efb9e80ac24bd72a9b2darylm
4994710c53dcad1ebf3755f3efb9e80ac24bd72a9b2darylm      */
5004710c53dcad1ebf3755f3efb9e80ac24bd72a9b2darylm
5014710c53dcad1ebf3755f3efb9e80ac24bd72a9b2darylm     PyAPI_FUNC(int) PyObject_AsReadBuffer(PyObject *obj,
5024710c53dcad1ebf3755f3efb9e80ac24bd72a9b2darylm                                          const void **buffer,
5034710c53dcad1ebf3755f3efb9e80ac24bd72a9b2darylm                                          Py_ssize_t *buffer_len);
5044710c53dcad1ebf3755f3efb9e80ac24bd72a9b2darylm
5054710c53dcad1ebf3755f3efb9e80ac24bd72a9b2darylm       /*
5064710c53dcad1ebf3755f3efb9e80ac24bd72a9b2darylm      Same as PyObject_AsCharBuffer() except that this API expects
5074710c53dcad1ebf3755f3efb9e80ac24bd72a9b2darylm      (readable, single segment) buffer interface and returns a
5084710c53dcad1ebf3755f3efb9e80ac24bd72a9b2darylm      pointer to a read-only memory location which can contain
5094710c53dcad1ebf3755f3efb9e80ac24bd72a9b2darylm      arbitrary data.
5104710c53dcad1ebf3755f3efb9e80ac24bd72a9b2darylm
5114710c53dcad1ebf3755f3efb9e80ac24bd72a9b2darylm      0 is returned on success.  buffer and buffer_len are only
5124710c53dcad1ebf3755f3efb9e80ac24bd72a9b2darylm      set in case no error occurs.  Otherwise, -1 is returned and
5134710c53dcad1ebf3755f3efb9e80ac24bd72a9b2darylm      an exception set.
5144710c53dcad1ebf3755f3efb9e80ac24bd72a9b2darylm
5154710c53dcad1ebf3755f3efb9e80ac24bd72a9b2darylm       */
5164710c53dcad1ebf3755f3efb9e80ac24bd72a9b2darylm
5174710c53dcad1ebf3755f3efb9e80ac24bd72a9b2darylm     PyAPI_FUNC(int) PyObject_AsWriteBuffer(PyObject *obj,
5184710c53dcad1ebf3755f3efb9e80ac24bd72a9b2darylm                                           void **buffer,
5194710c53dcad1ebf3755f3efb9e80ac24bd72a9b2darylm                                           Py_ssize_t *buffer_len);
5204710c53dcad1ebf3755f3efb9e80ac24bd72a9b2darylm
5214710c53dcad1ebf3755f3efb9e80ac24bd72a9b2darylm       /*
5224710c53dcad1ebf3755f3efb9e80ac24bd72a9b2darylm      Takes an arbitrary object which must support the (writeable,
5234710c53dcad1ebf3755f3efb9e80ac24bd72a9b2darylm      single segment) buffer interface and returns a pointer to a
5244710c53dcad1ebf3755f3efb9e80ac24bd72a9b2darylm      writeable memory location in buffer of size buffer_len.
5254710c53dcad1ebf3755f3efb9e80ac24bd72a9b2darylm
5264710c53dcad1ebf3755f3efb9e80ac24bd72a9b2darylm      0 is returned on success.  buffer and buffer_len are only
5274710c53dcad1ebf3755f3efb9e80ac24bd72a9b2darylm      set in case no error occurs. Otherwise, -1 is returned and
5284710c53dcad1ebf3755f3efb9e80ac24bd72a9b2darylm      an exception set.
5294710c53dcad1ebf3755f3efb9e80ac24bd72a9b2darylm
5304710c53dcad1ebf3755f3efb9e80ac24bd72a9b2darylm       */
5314710c53dcad1ebf3755f3efb9e80ac24bd72a9b2darylm
5324710c53dcad1ebf3755f3efb9e80ac24bd72a9b2darylm    /* new buffer API */
5334710c53dcad1ebf3755f3efb9e80ac24bd72a9b2darylm
5344710c53dcad1ebf3755f3efb9e80ac24bd72a9b2darylm#define PyObject_CheckBuffer(obj) \
5354710c53dcad1ebf3755f3efb9e80ac24bd72a9b2darylm    (((obj)->ob_type->tp_as_buffer != NULL) &&                          \
5364710c53dcad1ebf3755f3efb9e80ac24bd72a9b2darylm     (PyType_HasFeature((obj)->ob_type, Py_TPFLAGS_HAVE_NEWBUFFER)) && \
5374710c53dcad1ebf3755f3efb9e80ac24bd72a9b2darylm     ((obj)->ob_type->tp_as_buffer->bf_getbuffer != NULL))
5384710c53dcad1ebf3755f3efb9e80ac24bd72a9b2darylm
5394710c53dcad1ebf3755f3efb9e80ac24bd72a9b2darylm    /* Return 1 if the getbuffer function is available, otherwise
5404710c53dcad1ebf3755f3efb9e80ac24bd72a9b2darylm       return 0 */
5414710c53dcad1ebf3755f3efb9e80ac24bd72a9b2darylm
5424710c53dcad1ebf3755f3efb9e80ac24bd72a9b2darylm     PyAPI_FUNC(int) PyObject_GetBuffer(PyObject *obj, Py_buffer *view,
5434710c53dcad1ebf3755f3efb9e80ac24bd72a9b2darylm                                        int flags);
5444710c53dcad1ebf3755f3efb9e80ac24bd72a9b2darylm
5454710c53dcad1ebf3755f3efb9e80ac24bd72a9b2darylm    /* This is a C-API version of the getbuffer function call.  It checks
5464710c53dcad1ebf3755f3efb9e80ac24bd72a9b2darylm       to make sure object has the required function pointer and issues the
5474710c53dcad1ebf3755f3efb9e80ac24bd72a9b2darylm       call.  Returns -1 and raises an error on failure and returns 0 on
5484710c53dcad1ebf3755f3efb9e80ac24bd72a9b2darylm       success
5494710c53dcad1ebf3755f3efb9e80ac24bd72a9b2darylm    */
5504710c53dcad1ebf3755f3efb9e80ac24bd72a9b2darylm
5514710c53dcad1ebf3755f3efb9e80ac24bd72a9b2darylm
5524710c53dcad1ebf3755f3efb9e80ac24bd72a9b2darylm     PyAPI_FUNC(void *) PyBuffer_GetPointer(Py_buffer *view, Py_ssize_t *indices);
5534710c53dcad1ebf3755f3efb9e80ac24bd72a9b2darylm
5544710c53dcad1ebf3755f3efb9e80ac24bd72a9b2darylm    /* Get the memory area pointed to by the indices for the buffer given.
5554710c53dcad1ebf3755f3efb9e80ac24bd72a9b2darylm       Note that view->ndim is the assumed size of indices
5564710c53dcad1ebf3755f3efb9e80ac24bd72a9b2darylm    */
5574710c53dcad1ebf3755f3efb9e80ac24bd72a9b2darylm
5584710c53dcad1ebf3755f3efb9e80ac24bd72a9b2darylm     PyAPI_FUNC(int) PyBuffer_SizeFromFormat(const char *);
5594710c53dcad1ebf3755f3efb9e80ac24bd72a9b2darylm
5604710c53dcad1ebf3755f3efb9e80ac24bd72a9b2darylm    /* Return the implied itemsize of the data-format area from a
5614710c53dcad1ebf3755f3efb9e80ac24bd72a9b2darylm       struct-style description */
5624710c53dcad1ebf3755f3efb9e80ac24bd72a9b2darylm
5634710c53dcad1ebf3755f3efb9e80ac24bd72a9b2darylm
5644710c53dcad1ebf3755f3efb9e80ac24bd72a9b2darylm
5654710c53dcad1ebf3755f3efb9e80ac24bd72a9b2darylm     PyAPI_FUNC(int) PyBuffer_ToContiguous(void *buf, Py_buffer *view,
5664710c53dcad1ebf3755f3efb9e80ac24bd72a9b2darylm                                           Py_ssize_t len, char fort);
5674710c53dcad1ebf3755f3efb9e80ac24bd72a9b2darylm
5684710c53dcad1ebf3755f3efb9e80ac24bd72a9b2darylm     PyAPI_FUNC(int) PyBuffer_FromContiguous(Py_buffer *view, void *buf,
5694710c53dcad1ebf3755f3efb9e80ac24bd72a9b2darylm                                             Py_ssize_t len, char fort);
5704710c53dcad1ebf3755f3efb9e80ac24bd72a9b2darylm
5714710c53dcad1ebf3755f3efb9e80ac24bd72a9b2darylm
5724710c53dcad1ebf3755f3efb9e80ac24bd72a9b2darylm    /* Copy len bytes of data from the contiguous chunk of memory
5734710c53dcad1ebf3755f3efb9e80ac24bd72a9b2darylm       pointed to by buf into the buffer exported by obj.  Return
5744710c53dcad1ebf3755f3efb9e80ac24bd72a9b2darylm       0 on success and return -1 and raise a PyBuffer_Error on
5754710c53dcad1ebf3755f3efb9e80ac24bd72a9b2darylm       error (i.e. the object does not have a buffer interface or
5764710c53dcad1ebf3755f3efb9e80ac24bd72a9b2darylm       it is not working).
5774710c53dcad1ebf3755f3efb9e80ac24bd72a9b2darylm
5784710c53dcad1ebf3755f3efb9e80ac24bd72a9b2darylm       If fort is 'F' and the object is multi-dimensional,
5794710c53dcad1ebf3755f3efb9e80ac24bd72a9b2darylm       then the data will be copied into the array in
5804710c53dcad1ebf3755f3efb9e80ac24bd72a9b2darylm       Fortran-style (first dimension varies the fastest).  If
5814710c53dcad1ebf3755f3efb9e80ac24bd72a9b2darylm       fort is 'C', then the data will be copied into the array
5824710c53dcad1ebf3755f3efb9e80ac24bd72a9b2darylm       in C-style (last dimension varies the fastest).  If fort
5834710c53dcad1ebf3755f3efb9e80ac24bd72a9b2darylm       is 'A', then it does not matter and the copy will be made
5844710c53dcad1ebf3755f3efb9e80ac24bd72a9b2darylm       in whatever way is more efficient.
5854710c53dcad1ebf3755f3efb9e80ac24bd72a9b2darylm
5864710c53dcad1ebf3755f3efb9e80ac24bd72a9b2darylm    */
5874710c53dcad1ebf3755f3efb9e80ac24bd72a9b2darylm
5884710c53dcad1ebf3755f3efb9e80ac24bd72a9b2darylm     PyAPI_FUNC(int) PyObject_CopyData(PyObject *dest, PyObject *src);
5894710c53dcad1ebf3755f3efb9e80ac24bd72a9b2darylm
5904710c53dcad1ebf3755f3efb9e80ac24bd72a9b2darylm    /* Copy the data from the src buffer to the buffer of destination
5914710c53dcad1ebf3755f3efb9e80ac24bd72a9b2darylm     */
5924710c53dcad1ebf3755f3efb9e80ac24bd72a9b2darylm
5934710c53dcad1ebf3755f3efb9e80ac24bd72a9b2darylm     PyAPI_FUNC(int) PyBuffer_IsContiguous(Py_buffer *view, char fort);
5944710c53dcad1ebf3755f3efb9e80ac24bd72a9b2darylm
5954710c53dcad1ebf3755f3efb9e80ac24bd72a9b2darylm
5964710c53dcad1ebf3755f3efb9e80ac24bd72a9b2darylm     PyAPI_FUNC(void) PyBuffer_FillContiguousStrides(int ndims,
5974710c53dcad1ebf3755f3efb9e80ac24bd72a9b2darylm                                                    Py_ssize_t *shape,
5984710c53dcad1ebf3755f3efb9e80ac24bd72a9b2darylm                                                    Py_ssize_t *strides,
5994710c53dcad1ebf3755f3efb9e80ac24bd72a9b2darylm                                                    int itemsize,
6004710c53dcad1ebf3755f3efb9e80ac24bd72a9b2darylm                                                    char fort);
6014710c53dcad1ebf3755f3efb9e80ac24bd72a9b2darylm
6024710c53dcad1ebf3755f3efb9e80ac24bd72a9b2darylm    /*  Fill the strides array with byte-strides of a contiguous
6034710c53dcad1ebf3755f3efb9e80ac24bd72a9b2darylm        (Fortran-style if fort is 'F' or C-style otherwise)
6044710c53dcad1ebf3755f3efb9e80ac24bd72a9b2darylm        array of the given shape with the given number of bytes
6054710c53dcad1ebf3755f3efb9e80ac24bd72a9b2darylm        per element.
6064710c53dcad1ebf3755f3efb9e80ac24bd72a9b2darylm    */
6074710c53dcad1ebf3755f3efb9e80ac24bd72a9b2darylm
6084710c53dcad1ebf3755f3efb9e80ac24bd72a9b2darylm     PyAPI_FUNC(int) PyBuffer_FillInfo(Py_buffer *view, PyObject *o, void *buf,
6094710c53dcad1ebf3755f3efb9e80ac24bd72a9b2darylm                                       Py_ssize_t len, int readonly,
6104710c53dcad1ebf3755f3efb9e80ac24bd72a9b2darylm                                       int flags);
6114710c53dcad1ebf3755f3efb9e80ac24bd72a9b2darylm
6124710c53dcad1ebf3755f3efb9e80ac24bd72a9b2darylm    /* Fills in a buffer-info structure correctly for an exporter
6134710c53dcad1ebf3755f3efb9e80ac24bd72a9b2darylm       that can only share a contiguous chunk of memory of
6144710c53dcad1ebf3755f3efb9e80ac24bd72a9b2darylm       "unsigned bytes" of the given length. Returns 0 on success
6154710c53dcad1ebf3755f3efb9e80ac24bd72a9b2darylm       and -1 (with raising an error) on error.
6164710c53dcad1ebf3755f3efb9e80ac24bd72a9b2darylm     */
6174710c53dcad1ebf3755f3efb9e80ac24bd72a9b2darylm
6184710c53dcad1ebf3755f3efb9e80ac24bd72a9b2darylm     PyAPI_FUNC(void) PyBuffer_Release(Py_buffer *view);
6194710c53dcad1ebf3755f3efb9e80ac24bd72a9b2darylm
6204710c53dcad1ebf3755f3efb9e80ac24bd72a9b2darylm       /* Releases a Py_buffer obtained from getbuffer ParseTuple's s*.
6214710c53dcad1ebf3755f3efb9e80ac24bd72a9b2darylm    */
6224710c53dcad1ebf3755f3efb9e80ac24bd72a9b2darylm
6234710c53dcad1ebf3755f3efb9e80ac24bd72a9b2darylm     PyAPI_FUNC(PyObject *) PyObject_Format(PyObject* obj,
6244710c53dcad1ebf3755f3efb9e80ac24bd72a9b2darylm                                            PyObject *format_spec);
6254710c53dcad1ebf3755f3efb9e80ac24bd72a9b2darylm       /*
6264710c53dcad1ebf3755f3efb9e80ac24bd72a9b2darylm     Takes an arbitrary object and returns the result of
6274710c53dcad1ebf3755f3efb9e80ac24bd72a9b2darylm     calling obj.__format__(format_spec).
6284710c53dcad1ebf3755f3efb9e80ac24bd72a9b2darylm       */
6294710c53dcad1ebf3755f3efb9e80ac24bd72a9b2darylm
6304710c53dcad1ebf3755f3efb9e80ac24bd72a9b2darylm/* Iterators */
6314710c53dcad1ebf3755f3efb9e80ac24bd72a9b2darylm
6324710c53dcad1ebf3755f3efb9e80ac24bd72a9b2darylm     PyAPI_FUNC(PyObject *) PyObject_GetIter(PyObject *);
6334710c53dcad1ebf3755f3efb9e80ac24bd72a9b2darylm     /* Takes an object and returns an iterator for it.
6344710c53dcad1ebf3755f3efb9e80ac24bd72a9b2darylm    This is typically a new iterator but if the argument
6354710c53dcad1ebf3755f3efb9e80ac24bd72a9b2darylm    is an iterator, this returns itself. */
6364710c53dcad1ebf3755f3efb9e80ac24bd72a9b2darylm
6374710c53dcad1ebf3755f3efb9e80ac24bd72a9b2darylm#define PyIter_Check(obj) \
6384710c53dcad1ebf3755f3efb9e80ac24bd72a9b2darylm    (PyType_HasFeature((obj)->ob_type, Py_TPFLAGS_HAVE_ITER) && \
6394710c53dcad1ebf3755f3efb9e80ac24bd72a9b2darylm     (obj)->ob_type->tp_iternext != NULL && \
6404710c53dcad1ebf3755f3efb9e80ac24bd72a9b2darylm     (obj)->ob_type->tp_iternext != &_PyObject_NextNotImplemented)
6414710c53dcad1ebf3755f3efb9e80ac24bd72a9b2darylm
6424710c53dcad1ebf3755f3efb9e80ac24bd72a9b2darylm     PyAPI_FUNC(PyObject *) PyIter_Next(PyObject *);
6434710c53dcad1ebf3755f3efb9e80ac24bd72a9b2darylm     /* Takes an iterator object and calls its tp_iternext slot,
6444710c53dcad1ebf3755f3efb9e80ac24bd72a9b2darylm    returning the next value.  If the iterator is exhausted,
6454710c53dcad1ebf3755f3efb9e80ac24bd72a9b2darylm    this returns NULL without setting an exception.
6464710c53dcad1ebf3755f3efb9e80ac24bd72a9b2darylm    NULL with an exception means an error occurred. */
6474710c53dcad1ebf3755f3efb9e80ac24bd72a9b2darylm
6484710c53dcad1ebf3755f3efb9e80ac24bd72a9b2darylm/*  Number Protocol:*/
6494710c53dcad1ebf3755f3efb9e80ac24bd72a9b2darylm
6504710c53dcad1ebf3755f3efb9e80ac24bd72a9b2darylm     PyAPI_FUNC(int) PyNumber_Check(PyObject *o);
6514710c53dcad1ebf3755f3efb9e80ac24bd72a9b2darylm
6524710c53dcad1ebf3755f3efb9e80ac24bd72a9b2darylm       /*
6534710c53dcad1ebf3755f3efb9e80ac24bd72a9b2darylm     Returns 1 if the object, o, provides numeric protocols, and
6544710c53dcad1ebf3755f3efb9e80ac24bd72a9b2darylm     false otherwise.
6554710c53dcad1ebf3755f3efb9e80ac24bd72a9b2darylm
6564710c53dcad1ebf3755f3efb9e80ac24bd72a9b2darylm     This function always succeeds.
6574710c53dcad1ebf3755f3efb9e80ac24bd72a9b2darylm
6584710c53dcad1ebf3755f3efb9e80ac24bd72a9b2darylm       */
6594710c53dcad1ebf3755f3efb9e80ac24bd72a9b2darylm
6604710c53dcad1ebf3755f3efb9e80ac24bd72a9b2darylm     PyAPI_FUNC(PyObject *) PyNumber_Add(PyObject *o1, PyObject *o2);
6614710c53dcad1ebf3755f3efb9e80ac24bd72a9b2darylm
6624710c53dcad1ebf3755f3efb9e80ac24bd72a9b2darylm       /*
6634710c53dcad1ebf3755f3efb9e80ac24bd72a9b2darylm     Returns the result of adding o1 and o2, or null on failure.
6644710c53dcad1ebf3755f3efb9e80ac24bd72a9b2darylm     This is the equivalent of the Python expression: o1+o2.
6654710c53dcad1ebf3755f3efb9e80ac24bd72a9b2darylm
6664710c53dcad1ebf3755f3efb9e80ac24bd72a9b2darylm
6674710c53dcad1ebf3755f3efb9e80ac24bd72a9b2darylm       */
6684710c53dcad1ebf3755f3efb9e80ac24bd72a9b2darylm
6694710c53dcad1ebf3755f3efb9e80ac24bd72a9b2darylm     PyAPI_FUNC(PyObject *) PyNumber_Subtract(PyObject *o1, PyObject *o2);
6704710c53dcad1ebf3755f3efb9e80ac24bd72a9b2darylm
6714710c53dcad1ebf3755f3efb9e80ac24bd72a9b2darylm       /*
6724710c53dcad1ebf3755f3efb9e80ac24bd72a9b2darylm     Returns the result of subtracting o2 from o1, or null on
6734710c53dcad1ebf3755f3efb9e80ac24bd72a9b2darylm     failure.  This is the equivalent of the Python expression:
6744710c53dcad1ebf3755f3efb9e80ac24bd72a9b2darylm     o1-o2.
6754710c53dcad1ebf3755f3efb9e80ac24bd72a9b2darylm
6764710c53dcad1ebf3755f3efb9e80ac24bd72a9b2darylm       */
6774710c53dcad1ebf3755f3efb9e80ac24bd72a9b2darylm
6784710c53dcad1ebf3755f3efb9e80ac24bd72a9b2darylm     PyAPI_FUNC(PyObject *) PyNumber_Multiply(PyObject *o1, PyObject *o2);
6794710c53dcad1ebf3755f3efb9e80ac24bd72a9b2darylm
6804710c53dcad1ebf3755f3efb9e80ac24bd72a9b2darylm       /*
6814710c53dcad1ebf3755f3efb9e80ac24bd72a9b2darylm     Returns the result of multiplying o1 and o2, or null on
6824710c53dcad1ebf3755f3efb9e80ac24bd72a9b2darylm     failure.  This is the equivalent of the Python expression:
6834710c53dcad1ebf3755f3efb9e80ac24bd72a9b2darylm     o1*o2.
6844710c53dcad1ebf3755f3efb9e80ac24bd72a9b2darylm
6854710c53dcad1ebf3755f3efb9e80ac24bd72a9b2darylm
6864710c53dcad1ebf3755f3efb9e80ac24bd72a9b2darylm       */
6874710c53dcad1ebf3755f3efb9e80ac24bd72a9b2darylm
6884710c53dcad1ebf3755f3efb9e80ac24bd72a9b2darylm     PyAPI_FUNC(PyObject *) PyNumber_Divide(PyObject *o1, PyObject *o2);
6894710c53dcad1ebf3755f3efb9e80ac24bd72a9b2darylm
6904710c53dcad1ebf3755f3efb9e80ac24bd72a9b2darylm       /*
6914710c53dcad1ebf3755f3efb9e80ac24bd72a9b2darylm     Returns the result of dividing o1 by o2, or null on failure.
6924710c53dcad1ebf3755f3efb9e80ac24bd72a9b2darylm     This is the equivalent of the Python expression: o1/o2.
6934710c53dcad1ebf3755f3efb9e80ac24bd72a9b2darylm
6944710c53dcad1ebf3755f3efb9e80ac24bd72a9b2darylm
6954710c53dcad1ebf3755f3efb9e80ac24bd72a9b2darylm       */
6964710c53dcad1ebf3755f3efb9e80ac24bd72a9b2darylm
6974710c53dcad1ebf3755f3efb9e80ac24bd72a9b2darylm     PyAPI_FUNC(PyObject *) PyNumber_FloorDivide(PyObject *o1, PyObject *o2);
6984710c53dcad1ebf3755f3efb9e80ac24bd72a9b2darylm
6994710c53dcad1ebf3755f3efb9e80ac24bd72a9b2darylm       /*
7004710c53dcad1ebf3755f3efb9e80ac24bd72a9b2darylm     Returns the result of dividing o1 by o2 giving an integral result,
7014710c53dcad1ebf3755f3efb9e80ac24bd72a9b2darylm     or null on failure.
7024710c53dcad1ebf3755f3efb9e80ac24bd72a9b2darylm     This is the equivalent of the Python expression: o1//o2.
7034710c53dcad1ebf3755f3efb9e80ac24bd72a9b2darylm
7044710c53dcad1ebf3755f3efb9e80ac24bd72a9b2darylm
7054710c53dcad1ebf3755f3efb9e80ac24bd72a9b2darylm       */
7064710c53dcad1ebf3755f3efb9e80ac24bd72a9b2darylm
7074710c53dcad1ebf3755f3efb9e80ac24bd72a9b2darylm     PyAPI_FUNC(PyObject *) PyNumber_TrueDivide(PyObject *o1, PyObject *o2);
7084710c53dcad1ebf3755f3efb9e80ac24bd72a9b2darylm
7094710c53dcad1ebf3755f3efb9e80ac24bd72a9b2darylm       /*
7104710c53dcad1ebf3755f3efb9e80ac24bd72a9b2darylm     Returns the result of dividing o1 by o2 giving a float result,
7114710c53dcad1ebf3755f3efb9e80ac24bd72a9b2darylm     or null on failure.
7124710c53dcad1ebf3755f3efb9e80ac24bd72a9b2darylm     This is the equivalent of the Python expression: o1/o2.
7134710c53dcad1ebf3755f3efb9e80ac24bd72a9b2darylm
7144710c53dcad1ebf3755f3efb9e80ac24bd72a9b2darylm
7154710c53dcad1ebf3755f3efb9e80ac24bd72a9b2darylm       */
7164710c53dcad1ebf3755f3efb9e80ac24bd72a9b2darylm
7174710c53dcad1ebf3755f3efb9e80ac24bd72a9b2darylm     PyAPI_FUNC(PyObject *) PyNumber_Remainder(PyObject *o1, PyObject *o2);
7184710c53dcad1ebf3755f3efb9e80ac24bd72a9b2darylm
7194710c53dcad1ebf3755f3efb9e80ac24bd72a9b2darylm       /*
7204710c53dcad1ebf3755f3efb9e80ac24bd72a9b2darylm     Returns the remainder of dividing o1 by o2, or null on
7214710c53dcad1ebf3755f3efb9e80ac24bd72a9b2darylm     failure.  This is the equivalent of the Python expression:
7224710c53dcad1ebf3755f3efb9e80ac24bd72a9b2darylm     o1%o2.
7234710c53dcad1ebf3755f3efb9e80ac24bd72a9b2darylm
7244710c53dcad1ebf3755f3efb9e80ac24bd72a9b2darylm
7254710c53dcad1ebf3755f3efb9e80ac24bd72a9b2darylm       */
7264710c53dcad1ebf3755f3efb9e80ac24bd72a9b2darylm
7274710c53dcad1ebf3755f3efb9e80ac24bd72a9b2darylm     PyAPI_FUNC(PyObject *) PyNumber_Divmod(PyObject *o1, PyObject *o2);
7284710c53dcad1ebf3755f3efb9e80ac24bd72a9b2darylm
7294710c53dcad1ebf3755f3efb9e80ac24bd72a9b2darylm       /*
7304710c53dcad1ebf3755f3efb9e80ac24bd72a9b2darylm     See the built-in function divmod.  Returns NULL on failure.
7314710c53dcad1ebf3755f3efb9e80ac24bd72a9b2darylm     This is the equivalent of the Python expression:
7324710c53dcad1ebf3755f3efb9e80ac24bd72a9b2darylm     divmod(o1,o2).
7334710c53dcad1ebf3755f3efb9e80ac24bd72a9b2darylm
7344710c53dcad1ebf3755f3efb9e80ac24bd72a9b2darylm
7354710c53dcad1ebf3755f3efb9e80ac24bd72a9b2darylm       */
7364710c53dcad1ebf3755f3efb9e80ac24bd72a9b2darylm
7374710c53dcad1ebf3755f3efb9e80ac24bd72a9b2darylm     PyAPI_FUNC(PyObject *) PyNumber_Power(PyObject *o1, PyObject *o2,
7384710c53dcad1ebf3755f3efb9e80ac24bd72a9b2darylm                                          PyObject *o3);
7394710c53dcad1ebf3755f3efb9e80ac24bd72a9b2darylm
7404710c53dcad1ebf3755f3efb9e80ac24bd72a9b2darylm       /*
7414710c53dcad1ebf3755f3efb9e80ac24bd72a9b2darylm     See the built-in function pow.  Returns NULL on failure.
7424710c53dcad1ebf3755f3efb9e80ac24bd72a9b2darylm     This is the equivalent of the Python expression:
7434710c53dcad1ebf3755f3efb9e80ac24bd72a9b2darylm     pow(o1,o2,o3), where o3 is optional.
7444710c53dcad1ebf3755f3efb9e80ac24bd72a9b2darylm
7454710c53dcad1ebf3755f3efb9e80ac24bd72a9b2darylm       */
7464710c53dcad1ebf3755f3efb9e80ac24bd72a9b2darylm
7474710c53dcad1ebf3755f3efb9e80ac24bd72a9b2darylm     PyAPI_FUNC(PyObject *) PyNumber_Negative(PyObject *o);
7484710c53dcad1ebf3755f3efb9e80ac24bd72a9b2darylm
7494710c53dcad1ebf3755f3efb9e80ac24bd72a9b2darylm       /*
7504710c53dcad1ebf3755f3efb9e80ac24bd72a9b2darylm     Returns the negation of o on success, or null on failure.
7514710c53dcad1ebf3755f3efb9e80ac24bd72a9b2darylm     This is the equivalent of the Python expression: -o.
7524710c53dcad1ebf3755f3efb9e80ac24bd72a9b2darylm
7534710c53dcad1ebf3755f3efb9e80ac24bd72a9b2darylm       */
7544710c53dcad1ebf3755f3efb9e80ac24bd72a9b2darylm
7554710c53dcad1ebf3755f3efb9e80ac24bd72a9b2darylm     PyAPI_FUNC(PyObject *) PyNumber_Positive(PyObject *o);
7564710c53dcad1ebf3755f3efb9e80ac24bd72a9b2darylm
7574710c53dcad1ebf3755f3efb9e80ac24bd72a9b2darylm       /*
7584710c53dcad1ebf3755f3efb9e80ac24bd72a9b2darylm     Returns the (what?) of o on success, or NULL on failure.
7594710c53dcad1ebf3755f3efb9e80ac24bd72a9b2darylm     This is the equivalent of the Python expression: +o.
7604710c53dcad1ebf3755f3efb9e80ac24bd72a9b2darylm
7614710c53dcad1ebf3755f3efb9e80ac24bd72a9b2darylm       */
7624710c53dcad1ebf3755f3efb9e80ac24bd72a9b2darylm
7634710c53dcad1ebf3755f3efb9e80ac24bd72a9b2darylm     PyAPI_FUNC(PyObject *) PyNumber_Absolute(PyObject *o);
7644710c53dcad1ebf3755f3efb9e80ac24bd72a9b2darylm
7654710c53dcad1ebf3755f3efb9e80ac24bd72a9b2darylm       /*
7664710c53dcad1ebf3755f3efb9e80ac24bd72a9b2darylm     Returns the absolute value of o, or null on failure.  This is
7674710c53dcad1ebf3755f3efb9e80ac24bd72a9b2darylm     the equivalent of the Python expression: abs(o).
7684710c53dcad1ebf3755f3efb9e80ac24bd72a9b2darylm
7694710c53dcad1ebf3755f3efb9e80ac24bd72a9b2darylm       */
7704710c53dcad1ebf3755f3efb9e80ac24bd72a9b2darylm
7714710c53dcad1ebf3755f3efb9e80ac24bd72a9b2darylm     PyAPI_FUNC(PyObject *) PyNumber_Invert(PyObject *o);
7724710c53dcad1ebf3755f3efb9e80ac24bd72a9b2darylm
7734710c53dcad1ebf3755f3efb9e80ac24bd72a9b2darylm       /*
7744710c53dcad1ebf3755f3efb9e80ac24bd72a9b2darylm     Returns the bitwise negation of o on success, or NULL on
7754710c53dcad1ebf3755f3efb9e80ac24bd72a9b2darylm     failure.  This is the equivalent of the Python expression:
7764710c53dcad1ebf3755f3efb9e80ac24bd72a9b2darylm     ~o.
7774710c53dcad1ebf3755f3efb9e80ac24bd72a9b2darylm
7784710c53dcad1ebf3755f3efb9e80ac24bd72a9b2darylm
7794710c53dcad1ebf3755f3efb9e80ac24bd72a9b2darylm       */
7804710c53dcad1ebf3755f3efb9e80ac24bd72a9b2darylm
7814710c53dcad1ebf3755f3efb9e80ac24bd72a9b2darylm     PyAPI_FUNC(PyObject *) PyNumber_Lshift(PyObject *o1, PyObject *o2);
7824710c53dcad1ebf3755f3efb9e80ac24bd72a9b2darylm
7834710c53dcad1ebf3755f3efb9e80ac24bd72a9b2darylm       /*
7844710c53dcad1ebf3755f3efb9e80ac24bd72a9b2darylm     Returns the result of left shifting o1 by o2 on success, or
7854710c53dcad1ebf3755f3efb9e80ac24bd72a9b2darylm     NULL on failure.  This is the equivalent of the Python
7864710c53dcad1ebf3755f3efb9e80ac24bd72a9b2darylm     expression: o1 << o2.
7874710c53dcad1ebf3755f3efb9e80ac24bd72a9b2darylm
7884710c53dcad1ebf3755f3efb9e80ac24bd72a9b2darylm
7894710c53dcad1ebf3755f3efb9e80ac24bd72a9b2darylm       */
7904710c53dcad1ebf3755f3efb9e80ac24bd72a9b2darylm
7914710c53dcad1ebf3755f3efb9e80ac24bd72a9b2darylm     PyAPI_FUNC(PyObject *) PyNumber_Rshift(PyObject *o1, PyObject *o2);
7924710c53dcad1ebf3755f3efb9e80ac24bd72a9b2darylm
7934710c53dcad1ebf3755f3efb9e80ac24bd72a9b2darylm       /*
7944710c53dcad1ebf3755f3efb9e80ac24bd72a9b2darylm     Returns the result of right shifting o1 by o2 on success, or
7954710c53dcad1ebf3755f3efb9e80ac24bd72a9b2darylm     NULL on failure.  This is the equivalent of the Python
7964710c53dcad1ebf3755f3efb9e80ac24bd72a9b2darylm     expression: o1 >> o2.
7974710c53dcad1ebf3755f3efb9e80ac24bd72a9b2darylm
7984710c53dcad1ebf3755f3efb9e80ac24bd72a9b2darylm       */
7994710c53dcad1ebf3755f3efb9e80ac24bd72a9b2darylm
8004710c53dcad1ebf3755f3efb9e80ac24bd72a9b2darylm     PyAPI_FUNC(PyObject *) PyNumber_And(PyObject *o1, PyObject *o2);
8014710c53dcad1ebf3755f3efb9e80ac24bd72a9b2darylm
8024710c53dcad1ebf3755f3efb9e80ac24bd72a9b2darylm       /*
8034710c53dcad1ebf3755f3efb9e80ac24bd72a9b2darylm     Returns the result of bitwise and of o1 and o2 on success, or
8044710c53dcad1ebf3755f3efb9e80ac24bd72a9b2darylm     NULL on failure. This is the equivalent of the Python
8054710c53dcad1ebf3755f3efb9e80ac24bd72a9b2darylm     expression: o1&o2.
8064710c53dcad1ebf3755f3efb9e80ac24bd72a9b2darylm
8074710c53dcad1ebf3755f3efb9e80ac24bd72a9b2darylm
8084710c53dcad1ebf3755f3efb9e80ac24bd72a9b2darylm       */
8094710c53dcad1ebf3755f3efb9e80ac24bd72a9b2darylm
8104710c53dcad1ebf3755f3efb9e80ac24bd72a9b2darylm     PyAPI_FUNC(PyObject *) PyNumber_Xor(PyObject *o1, PyObject *o2);
8114710c53dcad1ebf3755f3efb9e80ac24bd72a9b2darylm
8124710c53dcad1ebf3755f3efb9e80ac24bd72a9b2darylm       /*
8134710c53dcad1ebf3755f3efb9e80ac24bd72a9b2darylm     Returns the bitwise exclusive or of o1 by o2 on success, or
8144710c53dcad1ebf3755f3efb9e80ac24bd72a9b2darylm     NULL on failure.  This is the equivalent of the Python
8154710c53dcad1ebf3755f3efb9e80ac24bd72a9b2darylm     expression: o1^o2.
8164710c53dcad1ebf3755f3efb9e80ac24bd72a9b2darylm
8174710c53dcad1ebf3755f3efb9e80ac24bd72a9b2darylm
8184710c53dcad1ebf3755f3efb9e80ac24bd72a9b2darylm       */
8194710c53dcad1ebf3755f3efb9e80ac24bd72a9b2darylm
8204710c53dcad1ebf3755f3efb9e80ac24bd72a9b2darylm     PyAPI_FUNC(PyObject *) PyNumber_Or(PyObject *o1, PyObject *o2);
8214710c53dcad1ebf3755f3efb9e80ac24bd72a9b2darylm
8224710c53dcad1ebf3755f3efb9e80ac24bd72a9b2darylm       /*
8234710c53dcad1ebf3755f3efb9e80ac24bd72a9b2darylm     Returns the result of bitwise or on o1 and o2 on success, or
8244710c53dcad1ebf3755f3efb9e80ac24bd72a9b2darylm     NULL on failure.  This is the equivalent of the Python
8254710c53dcad1ebf3755f3efb9e80ac24bd72a9b2darylm     expression: o1|o2.
8264710c53dcad1ebf3755f3efb9e80ac24bd72a9b2darylm
8274710c53dcad1ebf3755f3efb9e80ac24bd72a9b2darylm       */
8284710c53dcad1ebf3755f3efb9e80ac24bd72a9b2darylm
8294710c53dcad1ebf3755f3efb9e80ac24bd72a9b2darylm     /* Implemented elsewhere:
8304710c53dcad1ebf3755f3efb9e80ac24bd72a9b2darylm
8314710c53dcad1ebf3755f3efb9e80ac24bd72a9b2darylm     int PyNumber_Coerce(PyObject **p1, PyObject **p2);
8324710c53dcad1ebf3755f3efb9e80ac24bd72a9b2darylm
8334710c53dcad1ebf3755f3efb9e80ac24bd72a9b2darylm     This function takes the addresses of two variables of type
8344710c53dcad1ebf3755f3efb9e80ac24bd72a9b2darylm     PyObject*.
8354710c53dcad1ebf3755f3efb9e80ac24bd72a9b2darylm
8364710c53dcad1ebf3755f3efb9e80ac24bd72a9b2darylm     If the objects pointed to by *p1 and *p2 have the same type,
8374710c53dcad1ebf3755f3efb9e80ac24bd72a9b2darylm     increment their reference count and return 0 (success).
8384710c53dcad1ebf3755f3efb9e80ac24bd72a9b2darylm     If the objects can be converted to a common numeric type,
8394710c53dcad1ebf3755f3efb9e80ac24bd72a9b2darylm     replace *p1 and *p2 by their converted value (with 'new'
8404710c53dcad1ebf3755f3efb9e80ac24bd72a9b2darylm     reference counts), and return 0.
8414710c53dcad1ebf3755f3efb9e80ac24bd72a9b2darylm     If no conversion is possible, or if some other error occurs,
8424710c53dcad1ebf3755f3efb9e80ac24bd72a9b2darylm     return -1 (failure) and don't increment the reference counts.
8434710c53dcad1ebf3755f3efb9e80ac24bd72a9b2darylm     The call PyNumber_Coerce(&o1, &o2) is equivalent to the Python
8444710c53dcad1ebf3755f3efb9e80ac24bd72a9b2darylm     statement o1, o2 = coerce(o1, o2).
8454710c53dcad1ebf3755f3efb9e80ac24bd72a9b2darylm
8464710c53dcad1ebf3755f3efb9e80ac24bd72a9b2darylm       */
8474710c53dcad1ebf3755f3efb9e80ac24bd72a9b2darylm
8484710c53dcad1ebf3755f3efb9e80ac24bd72a9b2darylm#define PyIndex_Check(obj) \
8494710c53dcad1ebf3755f3efb9e80ac24bd72a9b2darylm   ((obj)->ob_type->tp_as_number != NULL && \
8504710c53dcad1ebf3755f3efb9e80ac24bd72a9b2darylm    PyType_HasFeature((obj)->ob_type, Py_TPFLAGS_HAVE_INDEX) && \
8514710c53dcad1ebf3755f3efb9e80ac24bd72a9b2darylm    (obj)->ob_type->tp_as_number->nb_index != NULL)
8524710c53dcad1ebf3755f3efb9e80ac24bd72a9b2darylm
8534710c53dcad1ebf3755f3efb9e80ac24bd72a9b2darylm     PyAPI_FUNC(PyObject *) PyNumber_Index(PyObject *o);
8544710c53dcad1ebf3755f3efb9e80ac24bd72a9b2darylm
8554710c53dcad1ebf3755f3efb9e80ac24bd72a9b2darylm       /*
8564710c53dcad1ebf3755f3efb9e80ac24bd72a9b2darylm     Returns the object converted to a Python long or int
8574710c53dcad1ebf3755f3efb9e80ac24bd72a9b2darylm     or NULL with an error raised on failure.
8584710c53dcad1ebf3755f3efb9e80ac24bd72a9b2darylm       */
8594710c53dcad1ebf3755f3efb9e80ac24bd72a9b2darylm
8604710c53dcad1ebf3755f3efb9e80ac24bd72a9b2darylm     PyAPI_FUNC(Py_ssize_t) PyNumber_AsSsize_t(PyObject *o, PyObject *exc);
8614710c53dcad1ebf3755f3efb9e80ac24bd72a9b2darylm
8624710c53dcad1ebf3755f3efb9e80ac24bd72a9b2darylm       /*
8634710c53dcad1ebf3755f3efb9e80ac24bd72a9b2darylm     Returns the Integral instance converted to an int. The
8644710c53dcad1ebf3755f3efb9e80ac24bd72a9b2darylm     instance is expected to be int or long or have an __int__
8654710c53dcad1ebf3755f3efb9e80ac24bd72a9b2darylm     method. Steals integral's reference. error_format will be
8664710c53dcad1ebf3755f3efb9e80ac24bd72a9b2darylm     used to create the TypeError if integral isn't actually an
8674710c53dcad1ebf3755f3efb9e80ac24bd72a9b2darylm     Integral instance. error_format should be a format string
8684710c53dcad1ebf3755f3efb9e80ac24bd72a9b2darylm     that can accept a char* naming integral's type.
8694710c53dcad1ebf3755f3efb9e80ac24bd72a9b2darylm       */
8704710c53dcad1ebf3755f3efb9e80ac24bd72a9b2darylm
8714710c53dcad1ebf3755f3efb9e80ac24bd72a9b2darylm     PyAPI_FUNC(PyObject *) _PyNumber_ConvertIntegralToInt(
8724710c53dcad1ebf3755f3efb9e80ac24bd72a9b2darylm         PyObject *integral,
8734710c53dcad1ebf3755f3efb9e80ac24bd72a9b2darylm         const char* error_format);
8744710c53dcad1ebf3755f3efb9e80ac24bd72a9b2darylm
8754710c53dcad1ebf3755f3efb9e80ac24bd72a9b2darylm       /*
8764710c53dcad1ebf3755f3efb9e80ac24bd72a9b2darylm    Returns the object converted to Py_ssize_t by going through
8774710c53dcad1ebf3755f3efb9e80ac24bd72a9b2darylm    PyNumber_Index first.  If an overflow error occurs while
8784710c53dcad1ebf3755f3efb9e80ac24bd72a9b2darylm    converting the int-or-long to Py_ssize_t, then the second argument
8794710c53dcad1ebf3755f3efb9e80ac24bd72a9b2darylm    is the error-type to return.  If it is NULL, then the overflow error
8804710c53dcad1ebf3755f3efb9e80ac24bd72a9b2darylm    is cleared and the value is clipped.
8814710c53dcad1ebf3755f3efb9e80ac24bd72a9b2darylm       */
8824710c53dcad1ebf3755f3efb9e80ac24bd72a9b2darylm
8834710c53dcad1ebf3755f3efb9e80ac24bd72a9b2darylm     PyAPI_FUNC(PyObject *) PyNumber_Int(PyObject *o);
8844710c53dcad1ebf3755f3efb9e80ac24bd72a9b2darylm
8854710c53dcad1ebf3755f3efb9e80ac24bd72a9b2darylm       /*
8864710c53dcad1ebf3755f3efb9e80ac24bd72a9b2darylm     Returns the o converted to an integer object on success, or
8874710c53dcad1ebf3755f3efb9e80ac24bd72a9b2darylm     NULL on failure.  This is the equivalent of the Python
8884710c53dcad1ebf3755f3efb9e80ac24bd72a9b2darylm     expression: int(o).
8894710c53dcad1ebf3755f3efb9e80ac24bd72a9b2darylm
8904710c53dcad1ebf3755f3efb9e80ac24bd72a9b2darylm       */
8914710c53dcad1ebf3755f3efb9e80ac24bd72a9b2darylm
8924710c53dcad1ebf3755f3efb9e80ac24bd72a9b2darylm     PyAPI_FUNC(PyObject *) PyNumber_Long(PyObject *o);
8934710c53dcad1ebf3755f3efb9e80ac24bd72a9b2darylm
8944710c53dcad1ebf3755f3efb9e80ac24bd72a9b2darylm       /*
8954710c53dcad1ebf3755f3efb9e80ac24bd72a9b2darylm     Returns the o converted to a long integer object on success,
8964710c53dcad1ebf3755f3efb9e80ac24bd72a9b2darylm     or NULL on failure.  This is the equivalent of the Python
8974710c53dcad1ebf3755f3efb9e80ac24bd72a9b2darylm     expression: long(o).
8984710c53dcad1ebf3755f3efb9e80ac24bd72a9b2darylm
8994710c53dcad1ebf3755f3efb9e80ac24bd72a9b2darylm       */
9004710c53dcad1ebf3755f3efb9e80ac24bd72a9b2darylm
9014710c53dcad1ebf3755f3efb9e80ac24bd72a9b2darylm     PyAPI_FUNC(PyObject *) PyNumber_Float(PyObject *o);
9024710c53dcad1ebf3755f3efb9e80ac24bd72a9b2darylm
9034710c53dcad1ebf3755f3efb9e80ac24bd72a9b2darylm       /*
9044710c53dcad1ebf3755f3efb9e80ac24bd72a9b2darylm     Returns the o converted to a float object on success, or NULL
9054710c53dcad1ebf3755f3efb9e80ac24bd72a9b2darylm     on failure.  This is the equivalent of the Python expression:
9064710c53dcad1ebf3755f3efb9e80ac24bd72a9b2darylm     float(o).
9074710c53dcad1ebf3755f3efb9e80ac24bd72a9b2darylm       */
9084710c53dcad1ebf3755f3efb9e80ac24bd72a9b2darylm
9094710c53dcad1ebf3755f3efb9e80ac24bd72a9b2darylm/*  In-place variants of (some of) the above number protocol functions */
9104710c53dcad1ebf3755f3efb9e80ac24bd72a9b2darylm
9114710c53dcad1ebf3755f3efb9e80ac24bd72a9b2darylm     PyAPI_FUNC(PyObject *) PyNumber_InPlaceAdd(PyObject *o1, PyObject *o2);
9124710c53dcad1ebf3755f3efb9e80ac24bd72a9b2darylm
9134710c53dcad1ebf3755f3efb9e80ac24bd72a9b2darylm       /*
9144710c53dcad1ebf3755f3efb9e80ac24bd72a9b2darylm     Returns the result of adding o2 to o1, possibly in-place, or null
9154710c53dcad1ebf3755f3efb9e80ac24bd72a9b2darylm     on failure.  This is the equivalent of the Python expression:
9164710c53dcad1ebf3755f3efb9e80ac24bd72a9b2darylm     o1 += o2.
9174710c53dcad1ebf3755f3efb9e80ac24bd72a9b2darylm
9184710c53dcad1ebf3755f3efb9e80ac24bd72a9b2darylm       */
9194710c53dcad1ebf3755f3efb9e80ac24bd72a9b2darylm
9204710c53dcad1ebf3755f3efb9e80ac24bd72a9b2darylm     PyAPI_FUNC(PyObject *) PyNumber_InPlaceSubtract(PyObject *o1, PyObject *o2);
9214710c53dcad1ebf3755f3efb9e80ac24bd72a9b2darylm
9224710c53dcad1ebf3755f3efb9e80ac24bd72a9b2darylm       /*
9234710c53dcad1ebf3755f3efb9e80ac24bd72a9b2darylm     Returns the result of subtracting o2 from o1, possibly in-place or
9244710c53dcad1ebf3755f3efb9e80ac24bd72a9b2darylm     null on failure.  This is the equivalent of the Python expression:
9254710c53dcad1ebf3755f3efb9e80ac24bd72a9b2darylm     o1 -= o2.
9264710c53dcad1ebf3755f3efb9e80ac24bd72a9b2darylm
9274710c53dcad1ebf3755f3efb9e80ac24bd72a9b2darylm       */
9284710c53dcad1ebf3755f3efb9e80ac24bd72a9b2darylm
9294710c53dcad1ebf3755f3efb9e80ac24bd72a9b2darylm     PyAPI_FUNC(PyObject *) PyNumber_InPlaceMultiply(PyObject *o1, PyObject *o2);
9304710c53dcad1ebf3755f3efb9e80ac24bd72a9b2darylm
9314710c53dcad1ebf3755f3efb9e80ac24bd72a9b2darylm       /*
9324710c53dcad1ebf3755f3efb9e80ac24bd72a9b2darylm     Returns the result of multiplying o1 by o2, possibly in-place, or
9334710c53dcad1ebf3755f3efb9e80ac24bd72a9b2darylm     null on failure.  This is the equivalent of the Python expression:
9344710c53dcad1ebf3755f3efb9e80ac24bd72a9b2darylm     o1 *= o2.
9354710c53dcad1ebf3755f3efb9e80ac24bd72a9b2darylm
9364710c53dcad1ebf3755f3efb9e80ac24bd72a9b2darylm       */
9374710c53dcad1ebf3755f3efb9e80ac24bd72a9b2darylm
9384710c53dcad1ebf3755f3efb9e80ac24bd72a9b2darylm     PyAPI_FUNC(PyObject *) PyNumber_InPlaceDivide(PyObject *o1, PyObject *o2);
9394710c53dcad1ebf3755f3efb9e80ac24bd72a9b2darylm
9404710c53dcad1ebf3755f3efb9e80ac24bd72a9b2darylm       /*
9414710c53dcad1ebf3755f3efb9e80ac24bd72a9b2darylm     Returns the result of dividing o1 by o2, possibly in-place, or null
9424710c53dcad1ebf3755f3efb9e80ac24bd72a9b2darylm     on failure.  This is the equivalent of the Python expression:
9434710c53dcad1ebf3755f3efb9e80ac24bd72a9b2darylm     o1 /= o2.
9444710c53dcad1ebf3755f3efb9e80ac24bd72a9b2darylm
9454710c53dcad1ebf3755f3efb9e80ac24bd72a9b2darylm       */
9464710c53dcad1ebf3755f3efb9e80ac24bd72a9b2darylm
9474710c53dcad1ebf3755f3efb9e80ac24bd72a9b2darylm     PyAPI_FUNC(PyObject *) PyNumber_InPlaceFloorDivide(PyObject *o1,
9484710c53dcad1ebf3755f3efb9e80ac24bd72a9b2darylm                                                       PyObject *o2);
9494710c53dcad1ebf3755f3efb9e80ac24bd72a9b2darylm
9504710c53dcad1ebf3755f3efb9e80ac24bd72a9b2darylm       /*
9514710c53dcad1ebf3755f3efb9e80ac24bd72a9b2darylm     Returns the result of dividing o1 by o2 giving an integral result,
9524710c53dcad1ebf3755f3efb9e80ac24bd72a9b2darylm     possibly in-place, or null on failure.
9534710c53dcad1ebf3755f3efb9e80ac24bd72a9b2darylm     This is the equivalent of the Python expression:
9544710c53dcad1ebf3755f3efb9e80ac24bd72a9b2darylm     o1 /= o2.
9554710c53dcad1ebf3755f3efb9e80ac24bd72a9b2darylm
9564710c53dcad1ebf3755f3efb9e80ac24bd72a9b2darylm       */
9574710c53dcad1ebf3755f3efb9e80ac24bd72a9b2darylm
9584710c53dcad1ebf3755f3efb9e80ac24bd72a9b2darylm     PyAPI_FUNC(PyObject *) PyNumber_InPlaceTrueDivide(PyObject *o1,
9594710c53dcad1ebf3755f3efb9e80ac24bd72a9b2darylm                                                      PyObject *o2);
9604710c53dcad1ebf3755f3efb9e80ac24bd72a9b2darylm
9614710c53dcad1ebf3755f3efb9e80ac24bd72a9b2darylm       /*
9624710c53dcad1ebf3755f3efb9e80ac24bd72a9b2darylm     Returns the result of dividing o1 by o2 giving a float result,
9634710c53dcad1ebf3755f3efb9e80ac24bd72a9b2darylm     possibly in-place, or null on failure.
9644710c53dcad1ebf3755f3efb9e80ac24bd72a9b2darylm     This is the equivalent of the Python expression:
9654710c53dcad1ebf3755f3efb9e80ac24bd72a9b2darylm     o1 /= o2.
9664710c53dcad1ebf3755f3efb9e80ac24bd72a9b2darylm
9674710c53dcad1ebf3755f3efb9e80ac24bd72a9b2darylm       */
9684710c53dcad1ebf3755f3efb9e80ac24bd72a9b2darylm
9694710c53dcad1ebf3755f3efb9e80ac24bd72a9b2darylm     PyAPI_FUNC(PyObject *) PyNumber_InPlaceRemainder(PyObject *o1, PyObject *o2);
9704710c53dcad1ebf3755f3efb9e80ac24bd72a9b2darylm
9714710c53dcad1ebf3755f3efb9e80ac24bd72a9b2darylm       /*
9724710c53dcad1ebf3755f3efb9e80ac24bd72a9b2darylm     Returns the remainder of dividing o1 by o2, possibly in-place, or
9734710c53dcad1ebf3755f3efb9e80ac24bd72a9b2darylm     null on failure.  This is the equivalent of the Python expression:
9744710c53dcad1ebf3755f3efb9e80ac24bd72a9b2darylm     o1 %= o2.
9754710c53dcad1ebf3755f3efb9e80ac24bd72a9b2darylm
9764710c53dcad1ebf3755f3efb9e80ac24bd72a9b2darylm       */
9774710c53dcad1ebf3755f3efb9e80ac24bd72a9b2darylm
9784710c53dcad1ebf3755f3efb9e80ac24bd72a9b2darylm     PyAPI_FUNC(PyObject *) PyNumber_InPlacePower(PyObject *o1, PyObject *o2,
9794710c53dcad1ebf3755f3efb9e80ac24bd72a9b2darylm                                                 PyObject *o3);
9804710c53dcad1ebf3755f3efb9e80ac24bd72a9b2darylm
9814710c53dcad1ebf3755f3efb9e80ac24bd72a9b2darylm       /*
9824710c53dcad1ebf3755f3efb9e80ac24bd72a9b2darylm     Returns the result of raising o1 to the power of o2, possibly
9834710c53dcad1ebf3755f3efb9e80ac24bd72a9b2darylm     in-place, or null on failure.  This is the equivalent of the Python
9844710c53dcad1ebf3755f3efb9e80ac24bd72a9b2darylm     expression: o1 **= o2, or pow(o1, o2, o3) if o3 is present.
9854710c53dcad1ebf3755f3efb9e80ac24bd72a9b2darylm
9864710c53dcad1ebf3755f3efb9e80ac24bd72a9b2darylm       */
9874710c53dcad1ebf3755f3efb9e80ac24bd72a9b2darylm
9884710c53dcad1ebf3755f3efb9e80ac24bd72a9b2darylm     PyAPI_FUNC(PyObject *) PyNumber_InPlaceLshift(PyObject *o1, PyObject *o2);
9894710c53dcad1ebf3755f3efb9e80ac24bd72a9b2darylm
9904710c53dcad1ebf3755f3efb9e80ac24bd72a9b2darylm       /*
9914710c53dcad1ebf3755f3efb9e80ac24bd72a9b2darylm     Returns the result of left shifting o1 by o2, possibly in-place, or
9924710c53dcad1ebf3755f3efb9e80ac24bd72a9b2darylm     null on failure.  This is the equivalent of the Python expression:
9934710c53dcad1ebf3755f3efb9e80ac24bd72a9b2darylm     o1 <<= o2.
9944710c53dcad1ebf3755f3efb9e80ac24bd72a9b2darylm
9954710c53dcad1ebf3755f3efb9e80ac24bd72a9b2darylm       */
9964710c53dcad1ebf3755f3efb9e80ac24bd72a9b2darylm
9974710c53dcad1ebf3755f3efb9e80ac24bd72a9b2darylm     PyAPI_FUNC(PyObject *) PyNumber_InPlaceRshift(PyObject *o1, PyObject *o2);
9984710c53dcad1ebf3755f3efb9e80ac24bd72a9b2darylm
9994710c53dcad1ebf3755f3efb9e80ac24bd72a9b2darylm       /*
10004710c53dcad1ebf3755f3efb9e80ac24bd72a9b2darylm     Returns the result of right shifting o1 by o2, possibly in-place or
10014710c53dcad1ebf3755f3efb9e80ac24bd72a9b2darylm     null on failure.  This is the equivalent of the Python expression:
10024710c53dcad1ebf3755f3efb9e80ac24bd72a9b2darylm     o1 >>= o2.
10034710c53dcad1ebf3755f3efb9e80ac24bd72a9b2darylm
10044710c53dcad1ebf3755f3efb9e80ac24bd72a9b2darylm       */
10054710c53dcad1ebf3755f3efb9e80ac24bd72a9b2darylm
10064710c53dcad1ebf3755f3efb9e80ac24bd72a9b2darylm     PyAPI_FUNC(PyObject *) PyNumber_InPlaceAnd(PyObject *o1, PyObject *o2);
10074710c53dcad1ebf3755f3efb9e80ac24bd72a9b2darylm
10084710c53dcad1ebf3755f3efb9e80ac24bd72a9b2darylm       /*
10094710c53dcad1ebf3755f3efb9e80ac24bd72a9b2darylm     Returns the result of bitwise and of o1 and o2, possibly in-place,
10104710c53dcad1ebf3755f3efb9e80ac24bd72a9b2darylm     or null on failure. This is the equivalent of the Python
10114710c53dcad1ebf3755f3efb9e80ac24bd72a9b2darylm     expression: o1 &= o2.
10124710c53dcad1ebf3755f3efb9e80ac24bd72a9b2darylm
10134710c53dcad1ebf3755f3efb9e80ac24bd72a9b2darylm       */
10144710c53dcad1ebf3755f3efb9e80ac24bd72a9b2darylm
10154710c53dcad1ebf3755f3efb9e80ac24bd72a9b2darylm     PyAPI_FUNC(PyObject *) PyNumber_InPlaceXor(PyObject *o1, PyObject *o2);
10164710c53dcad1ebf3755f3efb9e80ac24bd72a9b2darylm
10174710c53dcad1ebf3755f3efb9e80ac24bd72a9b2darylm       /*
10184710c53dcad1ebf3755f3efb9e80ac24bd72a9b2darylm     Returns the bitwise exclusive or of o1 by o2, possibly in-place, or
10194710c53dcad1ebf3755f3efb9e80ac24bd72a9b2darylm     null on failure.  This is the equivalent of the Python expression:
10204710c53dcad1ebf3755f3efb9e80ac24bd72a9b2darylm     o1 ^= o2.
10214710c53dcad1ebf3755f3efb9e80ac24bd72a9b2darylm
10224710c53dcad1ebf3755f3efb9e80ac24bd72a9b2darylm       */
10234710c53dcad1ebf3755f3efb9e80ac24bd72a9b2darylm
10244710c53dcad1ebf3755f3efb9e80ac24bd72a9b2darylm     PyAPI_FUNC(PyObject *) PyNumber_InPlaceOr(PyObject *o1, PyObject *o2);
10254710c53dcad1ebf3755f3efb9e80ac24bd72a9b2darylm
10264710c53dcad1ebf3755f3efb9e80ac24bd72a9b2darylm       /*
10274710c53dcad1ebf3755f3efb9e80ac24bd72a9b2darylm     Returns the result of bitwise or of o1 and o2, possibly in-place,
10284710c53dcad1ebf3755f3efb9e80ac24bd72a9b2darylm     or null on failure.  This is the equivalent of the Python
10294710c53dcad1ebf3755f3efb9e80ac24bd72a9b2darylm     expression: o1 |= o2.
10304710c53dcad1ebf3755f3efb9e80ac24bd72a9b2darylm
10314710c53dcad1ebf3755f3efb9e80ac24bd72a9b2darylm       */
10324710c53dcad1ebf3755f3efb9e80ac24bd72a9b2darylm
10334710c53dcad1ebf3755f3efb9e80ac24bd72a9b2darylm
10344710c53dcad1ebf3755f3efb9e80ac24bd72a9b2darylm     PyAPI_FUNC(PyObject *) PyNumber_ToBase(PyObject *n, int base);
10354710c53dcad1ebf3755f3efb9e80ac24bd72a9b2darylm
10364710c53dcad1ebf3755f3efb9e80ac24bd72a9b2darylm       /*
10374710c53dcad1ebf3755f3efb9e80ac24bd72a9b2darylm     Returns the integer n converted to a string with a base, with a base
10384710c53dcad1ebf3755f3efb9e80ac24bd72a9b2darylm     marker of 0b, 0o or 0x prefixed if applicable.
10394710c53dcad1ebf3755f3efb9e80ac24bd72a9b2darylm     If n is not an int object, it is converted with PyNumber_Index first.
10404710c53dcad1ebf3755f3efb9e80ac24bd72a9b2darylm       */
10414710c53dcad1ebf3755f3efb9e80ac24bd72a9b2darylm
10424710c53dcad1ebf3755f3efb9e80ac24bd72a9b2darylm
10434710c53dcad1ebf3755f3efb9e80ac24bd72a9b2darylm/*  Sequence protocol:*/
10444710c53dcad1ebf3755f3efb9e80ac24bd72a9b2darylm
10454710c53dcad1ebf3755f3efb9e80ac24bd72a9b2darylm     PyAPI_FUNC(int) PySequence_Check(PyObject *o);
10464710c53dcad1ebf3755f3efb9e80ac24bd72a9b2darylm
10474710c53dcad1ebf3755f3efb9e80ac24bd72a9b2darylm       /*
10484710c53dcad1ebf3755f3efb9e80ac24bd72a9b2darylm     Return 1 if the object provides sequence protocol, and zero
10494710c53dcad1ebf3755f3efb9e80ac24bd72a9b2darylm     otherwise.
10504710c53dcad1ebf3755f3efb9e80ac24bd72a9b2darylm
10514710c53dcad1ebf3755f3efb9e80ac24bd72a9b2darylm     This function always succeeds.
10524710c53dcad1ebf3755f3efb9e80ac24bd72a9b2darylm
10534710c53dcad1ebf3755f3efb9e80ac24bd72a9b2darylm       */
10544710c53dcad1ebf3755f3efb9e80ac24bd72a9b2darylm
10554710c53dcad1ebf3755f3efb9e80ac24bd72a9b2darylm     PyAPI_FUNC(Py_ssize_t) PySequence_Size(PyObject *o);
10564710c53dcad1ebf3755f3efb9e80ac24bd72a9b2darylm
10574710c53dcad1ebf3755f3efb9e80ac24bd72a9b2darylm       /*
10584710c53dcad1ebf3755f3efb9e80ac24bd72a9b2darylm     Return the size of sequence object o, or -1 on failure.
10594710c53dcad1ebf3755f3efb9e80ac24bd72a9b2darylm
10604710c53dcad1ebf3755f3efb9e80ac24bd72a9b2darylm       */
10614710c53dcad1ebf3755f3efb9e80ac24bd72a9b2darylm
10624710c53dcad1ebf3755f3efb9e80ac24bd72a9b2darylm       /* For DLL compatibility */
10634710c53dcad1ebf3755f3efb9e80ac24bd72a9b2darylm#undef PySequence_Length
10644710c53dcad1ebf3755f3efb9e80ac24bd72a9b2darylm     PyAPI_FUNC(Py_ssize_t) PySequence_Length(PyObject *o);
10654710c53dcad1ebf3755f3efb9e80ac24bd72a9b2darylm#define PySequence_Length PySequence_Size
10664710c53dcad1ebf3755f3efb9e80ac24bd72a9b2darylm
10674710c53dcad1ebf3755f3efb9e80ac24bd72a9b2darylm
10684710c53dcad1ebf3755f3efb9e80ac24bd72a9b2darylm     PyAPI_FUNC(PyObject *) PySequence_Concat(PyObject *o1, PyObject *o2);
10694710c53dcad1ebf3755f3efb9e80ac24bd72a9b2darylm
10704710c53dcad1ebf3755f3efb9e80ac24bd72a9b2darylm       /*
10714710c53dcad1ebf3755f3efb9e80ac24bd72a9b2darylm     Return the concatenation of o1 and o2 on success, and NULL on
10724710c53dcad1ebf3755f3efb9e80ac24bd72a9b2darylm     failure.   This is the equivalent of the Python
10734710c53dcad1ebf3755f3efb9e80ac24bd72a9b2darylm     expression: o1+o2.
10744710c53dcad1ebf3755f3efb9e80ac24bd72a9b2darylm
10754710c53dcad1ebf3755f3efb9e80ac24bd72a9b2darylm       */
10764710c53dcad1ebf3755f3efb9e80ac24bd72a9b2darylm
10774710c53dcad1ebf3755f3efb9e80ac24bd72a9b2darylm     PyAPI_FUNC(PyObject *) PySequence_Repeat(PyObject *o, Py_ssize_t count);
10784710c53dcad1ebf3755f3efb9e80ac24bd72a9b2darylm
10794710c53dcad1ebf3755f3efb9e80ac24bd72a9b2darylm       /*
10804710c53dcad1ebf3755f3efb9e80ac24bd72a9b2darylm     Return the result of repeating sequence object o count times,
10814710c53dcad1ebf3755f3efb9e80ac24bd72a9b2darylm     or NULL on failure.  This is the equivalent of the Python
10824710c53dcad1ebf3755f3efb9e80ac24bd72a9b2darylm     expression: o1*count.
10834710c53dcad1ebf3755f3efb9e80ac24bd72a9b2darylm
10844710c53dcad1ebf3755f3efb9e80ac24bd72a9b2darylm       */
10854710c53dcad1ebf3755f3efb9e80ac24bd72a9b2darylm
10864710c53dcad1ebf3755f3efb9e80ac24bd72a9b2darylm     PyAPI_FUNC(PyObject *) PySequence_GetItem(PyObject *o, Py_ssize_t i);
10874710c53dcad1ebf3755f3efb9e80ac24bd72a9b2darylm
10884710c53dcad1ebf3755f3efb9e80ac24bd72a9b2darylm       /*
10894710c53dcad1ebf3755f3efb9e80ac24bd72a9b2darylm     Return the ith element of o, or NULL on failure. This is the
10904710c53dcad1ebf3755f3efb9e80ac24bd72a9b2darylm     equivalent of the Python expression: o[i].
10914710c53dcad1ebf3755f3efb9e80ac24bd72a9b2darylm       */
10924710c53dcad1ebf3755f3efb9e80ac24bd72a9b2darylm
10934710c53dcad1ebf3755f3efb9e80ac24bd72a9b2darylm     PyAPI_FUNC(PyObject *) PySequence_GetSlice(PyObject *o, Py_ssize_t i1, Py_ssize_t i2);
10944710c53dcad1ebf3755f3efb9e80ac24bd72a9b2darylm
10954710c53dcad1ebf3755f3efb9e80ac24bd72a9b2darylm       /*
10964710c53dcad1ebf3755f3efb9e80ac24bd72a9b2darylm     Return the slice of sequence object o between i1 and i2, or
10974710c53dcad1ebf3755f3efb9e80ac24bd72a9b2darylm     NULL on failure. This is the equivalent of the Python
10984710c53dcad1ebf3755f3efb9e80ac24bd72a9b2darylm     expression: o[i1:i2].
10994710c53dcad1ebf3755f3efb9e80ac24bd72a9b2darylm
11004710c53dcad1ebf3755f3efb9e80ac24bd72a9b2darylm       */
11014710c53dcad1ebf3755f3efb9e80ac24bd72a9b2darylm
11024710c53dcad1ebf3755f3efb9e80ac24bd72a9b2darylm     PyAPI_FUNC(int) PySequence_SetItem(PyObject *o, Py_ssize_t i, PyObject *v);
11034710c53dcad1ebf3755f3efb9e80ac24bd72a9b2darylm
11044710c53dcad1ebf3755f3efb9e80ac24bd72a9b2darylm       /*
11054710c53dcad1ebf3755f3efb9e80ac24bd72a9b2darylm     Assign object v to the ith element of o.  Returns
11064710c53dcad1ebf3755f3efb9e80ac24bd72a9b2darylm     -1 on failure.  This is the equivalent of the Python
11074710c53dcad1ebf3755f3efb9e80ac24bd72a9b2darylm     statement: o[i]=v.
11084710c53dcad1ebf3755f3efb9e80ac24bd72a9b2darylm
11094710c53dcad1ebf3755f3efb9e80ac24bd72a9b2darylm       */
11104710c53dcad1ebf3755f3efb9e80ac24bd72a9b2darylm
11114710c53dcad1ebf3755f3efb9e80ac24bd72a9b2darylm     PyAPI_FUNC(int) PySequence_DelItem(PyObject *o, Py_ssize_t i);
11124710c53dcad1ebf3755f3efb9e80ac24bd72a9b2darylm
11134710c53dcad1ebf3755f3efb9e80ac24bd72a9b2darylm       /*
11144710c53dcad1ebf3755f3efb9e80ac24bd72a9b2darylm     Delete the ith element of object v.  Returns
11154710c53dcad1ebf3755f3efb9e80ac24bd72a9b2darylm     -1 on failure.  This is the equivalent of the Python
11164710c53dcad1ebf3755f3efb9e80ac24bd72a9b2darylm     statement: del o[i].
11174710c53dcad1ebf3755f3efb9e80ac24bd72a9b2darylm       */
11184710c53dcad1ebf3755f3efb9e80ac24bd72a9b2darylm
11194710c53dcad1ebf3755f3efb9e80ac24bd72a9b2darylm     PyAPI_FUNC(int) PySequence_SetSlice(PyObject *o, Py_ssize_t i1, Py_ssize_t i2,
11204710c53dcad1ebf3755f3efb9e80ac24bd72a9b2darylm                                        PyObject *v);
11214710c53dcad1ebf3755f3efb9e80ac24bd72a9b2darylm
11224710c53dcad1ebf3755f3efb9e80ac24bd72a9b2darylm       /*
11234710c53dcad1ebf3755f3efb9e80ac24bd72a9b2darylm     Assign the sequence object, v, to the slice in sequence
11244710c53dcad1ebf3755f3efb9e80ac24bd72a9b2darylm     object, o, from i1 to i2.  Returns -1 on failure. This is the
11254710c53dcad1ebf3755f3efb9e80ac24bd72a9b2darylm     equivalent of the Python statement: o[i1:i2]=v.
11264710c53dcad1ebf3755f3efb9e80ac24bd72a9b2darylm       */
11274710c53dcad1ebf3755f3efb9e80ac24bd72a9b2darylm
11284710c53dcad1ebf3755f3efb9e80ac24bd72a9b2darylm     PyAPI_FUNC(int) PySequence_DelSlice(PyObject *o, Py_ssize_t i1, Py_ssize_t i2);
11294710c53dcad1ebf3755f3efb9e80ac24bd72a9b2darylm
11304710c53dcad1ebf3755f3efb9e80ac24bd72a9b2darylm       /*
11314710c53dcad1ebf3755f3efb9e80ac24bd72a9b2darylm     Delete the slice in sequence object, o, from i1 to i2.
11324710c53dcad1ebf3755f3efb9e80ac24bd72a9b2darylm     Returns -1 on failure. This is the equivalent of the Python
11334710c53dcad1ebf3755f3efb9e80ac24bd72a9b2darylm     statement: del o[i1:i2].
11344710c53dcad1ebf3755f3efb9e80ac24bd72a9b2darylm       */
11354710c53dcad1ebf3755f3efb9e80ac24bd72a9b2darylm
11364710c53dcad1ebf3755f3efb9e80ac24bd72a9b2darylm     PyAPI_FUNC(PyObject *) PySequence_Tuple(PyObject *o);
11374710c53dcad1ebf3755f3efb9e80ac24bd72a9b2darylm
11384710c53dcad1ebf3755f3efb9e80ac24bd72a9b2darylm       /*
11394710c53dcad1ebf3755f3efb9e80ac24bd72a9b2darylm     Returns the sequence, o, as a tuple on success, and NULL on failure.
11404710c53dcad1ebf3755f3efb9e80ac24bd72a9b2darylm     This is equivalent to the Python expression: tuple(o)
11414710c53dcad1ebf3755f3efb9e80ac24bd72a9b2darylm       */
11424710c53dcad1ebf3755f3efb9e80ac24bd72a9b2darylm
11434710c53dcad1ebf3755f3efb9e80ac24bd72a9b2darylm
11444710c53dcad1ebf3755f3efb9e80ac24bd72a9b2darylm     PyAPI_FUNC(PyObject *) PySequence_List(PyObject *o);
11454710c53dcad1ebf3755f3efb9e80ac24bd72a9b2darylm       /*
11464710c53dcad1ebf3755f3efb9e80ac24bd72a9b2darylm     Returns the sequence, o, as a list on success, and NULL on failure.
11474710c53dcad1ebf3755f3efb9e80ac24bd72a9b2darylm     This is equivalent to the Python expression: list(o)
11484710c53dcad1ebf3755f3efb9e80ac24bd72a9b2darylm       */
11494710c53dcad1ebf3755f3efb9e80ac24bd72a9b2darylm
11504710c53dcad1ebf3755f3efb9e80ac24bd72a9b2darylm     PyAPI_FUNC(PyObject *) PySequence_Fast(PyObject *o, const char* m);
11514710c53dcad1ebf3755f3efb9e80ac24bd72a9b2darylm       /*
11524710c53dcad1ebf3755f3efb9e80ac24bd72a9b2darylm     Returns the sequence, o, as a tuple, unless it's already a
11534710c53dcad1ebf3755f3efb9e80ac24bd72a9b2darylm     tuple or list.  Use PySequence_Fast_GET_ITEM to access the
11544710c53dcad1ebf3755f3efb9e80ac24bd72a9b2darylm     members of this list, and PySequence_Fast_GET_SIZE to get its length.
11554710c53dcad1ebf3755f3efb9e80ac24bd72a9b2darylm
11564710c53dcad1ebf3755f3efb9e80ac24bd72a9b2darylm     Returns NULL on failure.  If the object does not support iteration,
11574710c53dcad1ebf3755f3efb9e80ac24bd72a9b2darylm     raises a TypeError exception with m as the message text.
11584710c53dcad1ebf3755f3efb9e80ac24bd72a9b2darylm       */
11594710c53dcad1ebf3755f3efb9e80ac24bd72a9b2darylm
11604710c53dcad1ebf3755f3efb9e80ac24bd72a9b2darylm#define PySequence_Fast_GET_SIZE(o) \
11614710c53dcad1ebf3755f3efb9e80ac24bd72a9b2darylm    (PyList_Check(o) ? PyList_GET_SIZE(o) : PyTuple_GET_SIZE(o))
11624710c53dcad1ebf3755f3efb9e80ac24bd72a9b2darylm       /*
11634710c53dcad1ebf3755f3efb9e80ac24bd72a9b2darylm     Return the size of o, assuming that o was returned by
11644710c53dcad1ebf3755f3efb9e80ac24bd72a9b2darylm     PySequence_Fast and is not NULL.
11654710c53dcad1ebf3755f3efb9e80ac24bd72a9b2darylm       */
11664710c53dcad1ebf3755f3efb9e80ac24bd72a9b2darylm
11674710c53dcad1ebf3755f3efb9e80ac24bd72a9b2darylm#define PySequence_Fast_GET_ITEM(o, i)\
11684710c53dcad1ebf3755f3efb9e80ac24bd72a9b2darylm     (PyList_Check(o) ? PyList_GET_ITEM(o, i) : PyTuple_GET_ITEM(o, i))
11694710c53dcad1ebf3755f3efb9e80ac24bd72a9b2darylm       /*
11704710c53dcad1ebf3755f3efb9e80ac24bd72a9b2darylm     Return the ith element of o, assuming that o was returned by
11714710c53dcad1ebf3755f3efb9e80ac24bd72a9b2darylm     PySequence_Fast, and that i is within bounds.
11724710c53dcad1ebf3755f3efb9e80ac24bd72a9b2darylm       */
11734710c53dcad1ebf3755f3efb9e80ac24bd72a9b2darylm
11744710c53dcad1ebf3755f3efb9e80ac24bd72a9b2darylm#define PySequence_ITEM(o, i)\
11754710c53dcad1ebf3755f3efb9e80ac24bd72a9b2darylm    ( Py_TYPE(o)->tp_as_sequence->sq_item(o, i) )
11764710c53dcad1ebf3755f3efb9e80ac24bd72a9b2darylm       /* Assume tp_as_sequence and sq_item exist and that i does not
11774710c53dcad1ebf3755f3efb9e80ac24bd72a9b2darylm      need to be corrected for a negative index
11784710c53dcad1ebf3755f3efb9e80ac24bd72a9b2darylm       */
11794710c53dcad1ebf3755f3efb9e80ac24bd72a9b2darylm
11804710c53dcad1ebf3755f3efb9e80ac24bd72a9b2darylm#define PySequence_Fast_ITEMS(sf) \
11814710c53dcad1ebf3755f3efb9e80ac24bd72a9b2darylm    (PyList_Check(sf) ? ((PyListObject *)(sf))->ob_item \
11824710c53dcad1ebf3755f3efb9e80ac24bd72a9b2darylm                      : ((PyTupleObject *)(sf))->ob_item)
11834710c53dcad1ebf3755f3efb9e80ac24bd72a9b2darylm    /* Return a pointer to the underlying item array for
11844710c53dcad1ebf3755f3efb9e80ac24bd72a9b2darylm       an object retured by PySequence_Fast */
11854710c53dcad1ebf3755f3efb9e80ac24bd72a9b2darylm
11864710c53dcad1ebf3755f3efb9e80ac24bd72a9b2darylm     PyAPI_FUNC(Py_ssize_t) PySequence_Count(PyObject *o, PyObject *value);
11874710c53dcad1ebf3755f3efb9e80ac24bd72a9b2darylm
11884710c53dcad1ebf3755f3efb9e80ac24bd72a9b2darylm       /*
11894710c53dcad1ebf3755f3efb9e80ac24bd72a9b2darylm     Return the number of occurrences on value on o, that is,
11904710c53dcad1ebf3755f3efb9e80ac24bd72a9b2darylm     return the number of keys for which o[key]==value.  On
11914710c53dcad1ebf3755f3efb9e80ac24bd72a9b2darylm     failure, return -1.  This is equivalent to the Python
11924710c53dcad1ebf3755f3efb9e80ac24bd72a9b2darylm     expression: o.count(value).
11934710c53dcad1ebf3755f3efb9e80ac24bd72a9b2darylm       */
11944710c53dcad1ebf3755f3efb9e80ac24bd72a9b2darylm
11954710c53dcad1ebf3755f3efb9e80ac24bd72a9b2darylm     PyAPI_FUNC(int) PySequence_Contains(PyObject *seq, PyObject *ob);
11964710c53dcad1ebf3755f3efb9e80ac24bd72a9b2darylm       /*
11974710c53dcad1ebf3755f3efb9e80ac24bd72a9b2darylm     Return -1 if error; 1 if ob in seq; 0 if ob not in seq.
11984710c53dcad1ebf3755f3efb9e80ac24bd72a9b2darylm     Use __contains__ if possible, else _PySequence_IterSearch().
11994710c53dcad1ebf3755f3efb9e80ac24bd72a9b2darylm       */
12004710c53dcad1ebf3755f3efb9e80ac24bd72a9b2darylm
12014710c53dcad1ebf3755f3efb9e80ac24bd72a9b2darylm#define PY_ITERSEARCH_COUNT    1
12024710c53dcad1ebf3755f3efb9e80ac24bd72a9b2darylm#define PY_ITERSEARCH_INDEX    2
12034710c53dcad1ebf3755f3efb9e80ac24bd72a9b2darylm#define PY_ITERSEARCH_CONTAINS 3
12044710c53dcad1ebf3755f3efb9e80ac24bd72a9b2darylm     PyAPI_FUNC(Py_ssize_t) _PySequence_IterSearch(PyObject *seq,
12054710c53dcad1ebf3755f3efb9e80ac24bd72a9b2darylm                                        PyObject *obj, int operation);
12064710c53dcad1ebf3755f3efb9e80ac24bd72a9b2darylm    /*
12074710c53dcad1ebf3755f3efb9e80ac24bd72a9b2darylm      Iterate over seq.  Result depends on the operation:
12084710c53dcad1ebf3755f3efb9e80ac24bd72a9b2darylm      PY_ITERSEARCH_COUNT:  return # of times obj appears in seq; -1 if
12094710c53dcad1ebf3755f3efb9e80ac24bd72a9b2darylm        error.
12104710c53dcad1ebf3755f3efb9e80ac24bd72a9b2darylm      PY_ITERSEARCH_INDEX:  return 0-based index of first occurrence of
12114710c53dcad1ebf3755f3efb9e80ac24bd72a9b2darylm        obj in seq; set ValueError and return -1 if none found;
12124710c53dcad1ebf3755f3efb9e80ac24bd72a9b2darylm        also return -1 on error.
12134710c53dcad1ebf3755f3efb9e80ac24bd72a9b2darylm      PY_ITERSEARCH_CONTAINS:  return 1 if obj in seq, else 0; -1 on
12144710c53dcad1ebf3755f3efb9e80ac24bd72a9b2darylm        error.
12154710c53dcad1ebf3755f3efb9e80ac24bd72a9b2darylm    */
12164710c53dcad1ebf3755f3efb9e80ac24bd72a9b2darylm
12174710c53dcad1ebf3755f3efb9e80ac24bd72a9b2darylm/* For DLL-level backwards compatibility */
12184710c53dcad1ebf3755f3efb9e80ac24bd72a9b2darylm#undef PySequence_In
12194710c53dcad1ebf3755f3efb9e80ac24bd72a9b2darylm     PyAPI_FUNC(int) PySequence_In(PyObject *o, PyObject *value);
12204710c53dcad1ebf3755f3efb9e80ac24bd72a9b2darylm
12214710c53dcad1ebf3755f3efb9e80ac24bd72a9b2darylm/* For source-level backwards compatibility */
12224710c53dcad1ebf3755f3efb9e80ac24bd72a9b2darylm#define PySequence_In PySequence_Contains
12234710c53dcad1ebf3755f3efb9e80ac24bd72a9b2darylm
12244710c53dcad1ebf3755f3efb9e80ac24bd72a9b2darylm       /*
12254710c53dcad1ebf3755f3efb9e80ac24bd72a9b2darylm     Determine if o contains value.  If an item in o is equal to
12264710c53dcad1ebf3755f3efb9e80ac24bd72a9b2darylm     X, return 1, otherwise return 0.  On error, return -1.  This
12274710c53dcad1ebf3755f3efb9e80ac24bd72a9b2darylm     is equivalent to the Python expression: value in o.
12284710c53dcad1ebf3755f3efb9e80ac24bd72a9b2darylm       */
12294710c53dcad1ebf3755f3efb9e80ac24bd72a9b2darylm
12304710c53dcad1ebf3755f3efb9e80ac24bd72a9b2darylm     PyAPI_FUNC(Py_ssize_t) PySequence_Index(PyObject *o, PyObject *value);
12314710c53dcad1ebf3755f3efb9e80ac24bd72a9b2darylm
12324710c53dcad1ebf3755f3efb9e80ac24bd72a9b2darylm       /*
12334710c53dcad1ebf3755f3efb9e80ac24bd72a9b2darylm     Return the first index for which o[i]=value.  On error,
12344710c53dcad1ebf3755f3efb9e80ac24bd72a9b2darylm     return -1.    This is equivalent to the Python
12354710c53dcad1ebf3755f3efb9e80ac24bd72a9b2darylm     expression: o.index(value).
12364710c53dcad1ebf3755f3efb9e80ac24bd72a9b2darylm       */
12374710c53dcad1ebf3755f3efb9e80ac24bd72a9b2darylm
12384710c53dcad1ebf3755f3efb9e80ac24bd72a9b2darylm/* In-place versions of some of the above Sequence functions. */
12394710c53dcad1ebf3755f3efb9e80ac24bd72a9b2darylm
12404710c53dcad1ebf3755f3efb9e80ac24bd72a9b2darylm     PyAPI_FUNC(PyObject *) PySequence_InPlaceConcat(PyObject *o1, PyObject *o2);
12414710c53dcad1ebf3755f3efb9e80ac24bd72a9b2darylm
12424710c53dcad1ebf3755f3efb9e80ac24bd72a9b2darylm       /*
12434710c53dcad1ebf3755f3efb9e80ac24bd72a9b2darylm     Append o2 to o1, in-place when possible. Return the resulting
12444710c53dcad1ebf3755f3efb9e80ac24bd72a9b2darylm     object, which could be o1, or NULL on failure.  This is the
12454710c53dcad1ebf3755f3efb9e80ac24bd72a9b2darylm     equivalent of the Python expression: o1 += o2.
12464710c53dcad1ebf3755f3efb9e80ac24bd72a9b2darylm
12474710c53dcad1ebf3755f3efb9e80ac24bd72a9b2darylm       */
12484710c53dcad1ebf3755f3efb9e80ac24bd72a9b2darylm
12494710c53dcad1ebf3755f3efb9e80ac24bd72a9b2darylm     PyAPI_FUNC(PyObject *) PySequence_InPlaceRepeat(PyObject *o, Py_ssize_t count);
12504710c53dcad1ebf3755f3efb9e80ac24bd72a9b2darylm
12514710c53dcad1ebf3755f3efb9e80ac24bd72a9b2darylm       /*
12524710c53dcad1ebf3755f3efb9e80ac24bd72a9b2darylm     Repeat o1 by count, in-place when possible. Return the resulting
12534710c53dcad1ebf3755f3efb9e80ac24bd72a9b2darylm     object, which could be o1, or NULL on failure.  This is the
12544710c53dcad1ebf3755f3efb9e80ac24bd72a9b2darylm     equivalent of the Python expression: o1 *= count.
12554710c53dcad1ebf3755f3efb9e80ac24bd72a9b2darylm
12564710c53dcad1ebf3755f3efb9e80ac24bd72a9b2darylm       */
12574710c53dcad1ebf3755f3efb9e80ac24bd72a9b2darylm
12584710c53dcad1ebf3755f3efb9e80ac24bd72a9b2darylm/*  Mapping protocol:*/
12594710c53dcad1ebf3755f3efb9e80ac24bd72a9b2darylm
12604710c53dcad1ebf3755f3efb9e80ac24bd72a9b2darylm     PyAPI_FUNC(int) PyMapping_Check(PyObject *o);
12614710c53dcad1ebf3755f3efb9e80ac24bd72a9b2darylm
12624710c53dcad1ebf3755f3efb9e80ac24bd72a9b2darylm       /*
12634710c53dcad1ebf3755f3efb9e80ac24bd72a9b2darylm     Return 1 if the object provides mapping protocol, and zero
12644710c53dcad1ebf3755f3efb9e80ac24bd72a9b2darylm     otherwise.
12654710c53dcad1ebf3755f3efb9e80ac24bd72a9b2darylm
12664710c53dcad1ebf3755f3efb9e80ac24bd72a9b2darylm     This function always succeeds.
12674710c53dcad1ebf3755f3efb9e80ac24bd72a9b2darylm       */
12684710c53dcad1ebf3755f3efb9e80ac24bd72a9b2darylm
12694710c53dcad1ebf3755f3efb9e80ac24bd72a9b2darylm     PyAPI_FUNC(Py_ssize_t) PyMapping_Size(PyObject *o);
12704710c53dcad1ebf3755f3efb9e80ac24bd72a9b2darylm
12714710c53dcad1ebf3755f3efb9e80ac24bd72a9b2darylm       /*
12724710c53dcad1ebf3755f3efb9e80ac24bd72a9b2darylm     Returns the number of keys in object o on success, and -1 on
12734710c53dcad1ebf3755f3efb9e80ac24bd72a9b2darylm     failure.  For objects that do not provide sequence protocol,
12744710c53dcad1ebf3755f3efb9e80ac24bd72a9b2darylm     this is equivalent to the Python expression: len(o).
12754710c53dcad1ebf3755f3efb9e80ac24bd72a9b2darylm       */
12764710c53dcad1ebf3755f3efb9e80ac24bd72a9b2darylm
12774710c53dcad1ebf3755f3efb9e80ac24bd72a9b2darylm       /* For DLL compatibility */
12784710c53dcad1ebf3755f3efb9e80ac24bd72a9b2darylm#undef PyMapping_Length
12794710c53dcad1ebf3755f3efb9e80ac24bd72a9b2darylm     PyAPI_FUNC(Py_ssize_t) PyMapping_Length(PyObject *o);
12804710c53dcad1ebf3755f3efb9e80ac24bd72a9b2darylm#define PyMapping_Length PyMapping_Size
12814710c53dcad1ebf3755f3efb9e80ac24bd72a9b2darylm
12824710c53dcad1ebf3755f3efb9e80ac24bd72a9b2darylm
12834710c53dcad1ebf3755f3efb9e80ac24bd72a9b2darylm     /* implemented as a macro:
12844710c53dcad1ebf3755f3efb9e80ac24bd72a9b2darylm
12854710c53dcad1ebf3755f3efb9e80ac24bd72a9b2darylm     int PyMapping_DelItemString(PyObject *o, char *key);
12864710c53dcad1ebf3755f3efb9e80ac24bd72a9b2darylm
12874710c53dcad1ebf3755f3efb9e80ac24bd72a9b2darylm     Remove the mapping for object, key, from the object *o.
12884710c53dcad1ebf3755f3efb9e80ac24bd72a9b2darylm     Returns -1 on failure.  This is equivalent to
12894710c53dcad1ebf3755f3efb9e80ac24bd72a9b2darylm     the Python statement: del o[key].
12904710c53dcad1ebf3755f3efb9e80ac24bd72a9b2darylm       */
12914710c53dcad1ebf3755f3efb9e80ac24bd72a9b2darylm#define PyMapping_DelItemString(O,K) PyObject_DelItemString((O),(K))
12924710c53dcad1ebf3755f3efb9e80ac24bd72a9b2darylm
12934710c53dcad1ebf3755f3efb9e80ac24bd72a9b2darylm     /* implemented as a macro:
12944710c53dcad1ebf3755f3efb9e80ac24bd72a9b2darylm
12954710c53dcad1ebf3755f3efb9e80ac24bd72a9b2darylm     int PyMapping_DelItem(PyObject *o, PyObject *key);
12964710c53dcad1ebf3755f3efb9e80ac24bd72a9b2darylm
12974710c53dcad1ebf3755f3efb9e80ac24bd72a9b2darylm     Remove the mapping for object, key, from the object *o.
12984710c53dcad1ebf3755f3efb9e80ac24bd72a9b2darylm     Returns -1 on failure.  This is equivalent to
12994710c53dcad1ebf3755f3efb9e80ac24bd72a9b2darylm     the Python statement: del o[key].
13004710c53dcad1ebf3755f3efb9e80ac24bd72a9b2darylm       */
13014710c53dcad1ebf3755f3efb9e80ac24bd72a9b2darylm#define PyMapping_DelItem(O,K) PyObject_DelItem((O),(K))
13024710c53dcad1ebf3755f3efb9e80ac24bd72a9b2darylm
13034710c53dcad1ebf3755f3efb9e80ac24bd72a9b2darylm     PyAPI_FUNC(int) PyMapping_HasKeyString(PyObject *o, char *key);
13044710c53dcad1ebf3755f3efb9e80ac24bd72a9b2darylm
13054710c53dcad1ebf3755f3efb9e80ac24bd72a9b2darylm       /*
13064710c53dcad1ebf3755f3efb9e80ac24bd72a9b2darylm     On success, return 1 if the mapping object has the key, key,
13074710c53dcad1ebf3755f3efb9e80ac24bd72a9b2darylm     and 0 otherwise.  This is equivalent to the Python expression:
13084710c53dcad1ebf3755f3efb9e80ac24bd72a9b2darylm     o.has_key(key).
13094710c53dcad1ebf3755f3efb9e80ac24bd72a9b2darylm
13104710c53dcad1ebf3755f3efb9e80ac24bd72a9b2darylm     This function always succeeds.
13114710c53dcad1ebf3755f3efb9e80ac24bd72a9b2darylm       */
13124710c53dcad1ebf3755f3efb9e80ac24bd72a9b2darylm
13134710c53dcad1ebf3755f3efb9e80ac24bd72a9b2darylm     PyAPI_FUNC(int) PyMapping_HasKey(PyObject *o, PyObject *key);
13144710c53dcad1ebf3755f3efb9e80ac24bd72a9b2darylm
13154710c53dcad1ebf3755f3efb9e80ac24bd72a9b2darylm       /*
13164710c53dcad1ebf3755f3efb9e80ac24bd72a9b2darylm     Return 1 if the mapping object has the key, key,
13174710c53dcad1ebf3755f3efb9e80ac24bd72a9b2darylm     and 0 otherwise.  This is equivalent to the Python expression:
13184710c53dcad1ebf3755f3efb9e80ac24bd72a9b2darylm     o.has_key(key).
13194710c53dcad1ebf3755f3efb9e80ac24bd72a9b2darylm
13204710c53dcad1ebf3755f3efb9e80ac24bd72a9b2darylm     This function always succeeds.
13214710c53dcad1ebf3755f3efb9e80ac24bd72a9b2darylm
13224710c53dcad1ebf3755f3efb9e80ac24bd72a9b2darylm       */
13234710c53dcad1ebf3755f3efb9e80ac24bd72a9b2darylm
13244710c53dcad1ebf3755f3efb9e80ac24bd72a9b2darylm     /* Implemented as macro:
13254710c53dcad1ebf3755f3efb9e80ac24bd72a9b2darylm
13264710c53dcad1ebf3755f3efb9e80ac24bd72a9b2darylm     PyObject *PyMapping_Keys(PyObject *o);
13274710c53dcad1ebf3755f3efb9e80ac24bd72a9b2darylm
13284710c53dcad1ebf3755f3efb9e80ac24bd72a9b2darylm     On success, return a list of the keys in object o.  On
13294710c53dcad1ebf3755f3efb9e80ac24bd72a9b2darylm     failure, return NULL. This is equivalent to the Python
13304710c53dcad1ebf3755f3efb9e80ac24bd72a9b2darylm     expression: o.keys().
13314710c53dcad1ebf3755f3efb9e80ac24bd72a9b2darylm       */
13324710c53dcad1ebf3755f3efb9e80ac24bd72a9b2darylm#define PyMapping_Keys(O) PyObject_CallMethod(O,"keys",NULL)
13334710c53dcad1ebf3755f3efb9e80ac24bd72a9b2darylm
13344710c53dcad1ebf3755f3efb9e80ac24bd72a9b2darylm     /* Implemented as macro:
13354710c53dcad1ebf3755f3efb9e80ac24bd72a9b2darylm
13364710c53dcad1ebf3755f3efb9e80ac24bd72a9b2darylm     PyObject *PyMapping_Values(PyObject *o);
13374710c53dcad1ebf3755f3efb9e80ac24bd72a9b2darylm
13384710c53dcad1ebf3755f3efb9e80ac24bd72a9b2darylm     On success, return a list of the values in object o.  On
13394710c53dcad1ebf3755f3efb9e80ac24bd72a9b2darylm     failure, return NULL. This is equivalent to the Python
13404710c53dcad1ebf3755f3efb9e80ac24bd72a9b2darylm     expression: o.values().
13414710c53dcad1ebf3755f3efb9e80ac24bd72a9b2darylm       */
13424710c53dcad1ebf3755f3efb9e80ac24bd72a9b2darylm#define PyMapping_Values(O) PyObject_CallMethod(O,"values",NULL)
13434710c53dcad1ebf3755f3efb9e80ac24bd72a9b2darylm
13444710c53dcad1ebf3755f3efb9e80ac24bd72a9b2darylm     /* Implemented as macro:
13454710c53dcad1ebf3755f3efb9e80ac24bd72a9b2darylm
13464710c53dcad1ebf3755f3efb9e80ac24bd72a9b2darylm     PyObject *PyMapping_Items(PyObject *o);
13474710c53dcad1ebf3755f3efb9e80ac24bd72a9b2darylm
13484710c53dcad1ebf3755f3efb9e80ac24bd72a9b2darylm     On success, return a list of the items in object o, where
13494710c53dcad1ebf3755f3efb9e80ac24bd72a9b2darylm     each item is a tuple containing a key-value pair.  On
13504710c53dcad1ebf3755f3efb9e80ac24bd72a9b2darylm     failure, return NULL. This is equivalent to the Python
13514710c53dcad1ebf3755f3efb9e80ac24bd72a9b2darylm     expression: o.items().
13524710c53dcad1ebf3755f3efb9e80ac24bd72a9b2darylm
13534710c53dcad1ebf3755f3efb9e80ac24bd72a9b2darylm       */
13544710c53dcad1ebf3755f3efb9e80ac24bd72a9b2darylm#define PyMapping_Items(O) PyObject_CallMethod(O,"items",NULL)
13554710c53dcad1ebf3755f3efb9e80ac24bd72a9b2darylm
13564710c53dcad1ebf3755f3efb9e80ac24bd72a9b2darylm     PyAPI_FUNC(PyObject *) PyMapping_GetItemString(PyObject *o, char *key);
13574710c53dcad1ebf3755f3efb9e80ac24bd72a9b2darylm
13584710c53dcad1ebf3755f3efb9e80ac24bd72a9b2darylm       /*
13594710c53dcad1ebf3755f3efb9e80ac24bd72a9b2darylm     Return element of o corresponding to the object, key, or NULL
13604710c53dcad1ebf3755f3efb9e80ac24bd72a9b2darylm     on failure. This is the equivalent of the Python expression:
13614710c53dcad1ebf3755f3efb9e80ac24bd72a9b2darylm     o[key].
13624710c53dcad1ebf3755f3efb9e80ac24bd72a9b2darylm       */
13634710c53dcad1ebf3755f3efb9e80ac24bd72a9b2darylm
13644710c53dcad1ebf3755f3efb9e80ac24bd72a9b2darylm     PyAPI_FUNC(int) PyMapping_SetItemString(PyObject *o, char *key,
13654710c53dcad1ebf3755f3efb9e80ac24bd72a9b2darylm                                            PyObject *value);
13664710c53dcad1ebf3755f3efb9e80ac24bd72a9b2darylm
13674710c53dcad1ebf3755f3efb9e80ac24bd72a9b2darylm       /*
13684710c53dcad1ebf3755f3efb9e80ac24bd72a9b2darylm     Map the object, key, to the value, v.  Returns
13694710c53dcad1ebf3755f3efb9e80ac24bd72a9b2darylm     -1 on failure.  This is the equivalent of the Python
13704710c53dcad1ebf3755f3efb9e80ac24bd72a9b2darylm     statement: o[key]=v.
13714710c53dcad1ebf3755f3efb9e80ac24bd72a9b2darylm      */
13724710c53dcad1ebf3755f3efb9e80ac24bd72a9b2darylm
13734710c53dcad1ebf3755f3efb9e80ac24bd72a9b2darylm
13744710c53dcad1ebf3755f3efb9e80ac24bd72a9b2darylmPyAPI_FUNC(int) PyObject_IsInstance(PyObject *object, PyObject *typeorclass);
13754710c53dcad1ebf3755f3efb9e80ac24bd72a9b2darylm      /* isinstance(object, typeorclass) */
13764710c53dcad1ebf3755f3efb9e80ac24bd72a9b2darylm
13774710c53dcad1ebf3755f3efb9e80ac24bd72a9b2darylmPyAPI_FUNC(int) PyObject_IsSubclass(PyObject *object, PyObject *typeorclass);
13784710c53dcad1ebf3755f3efb9e80ac24bd72a9b2darylm      /* issubclass(object, typeorclass) */
13794710c53dcad1ebf3755f3efb9e80ac24bd72a9b2darylm
13804710c53dcad1ebf3755f3efb9e80ac24bd72a9b2darylm
13814710c53dcad1ebf3755f3efb9e80ac24bd72a9b2darylmPyAPI_FUNC(int) _PyObject_RealIsInstance(PyObject *inst, PyObject *cls);
13824710c53dcad1ebf3755f3efb9e80ac24bd72a9b2darylm
13834710c53dcad1ebf3755f3efb9e80ac24bd72a9b2darylmPyAPI_FUNC(int) _PyObject_RealIsSubclass(PyObject *derived, PyObject *cls);
13844710c53dcad1ebf3755f3efb9e80ac24bd72a9b2darylm
13854710c53dcad1ebf3755f3efb9e80ac24bd72a9b2darylm
13864710c53dcad1ebf3755f3efb9e80ac24bd72a9b2darylm/* For internal use by buffer API functions */
13874710c53dcad1ebf3755f3efb9e80ac24bd72a9b2darylmPyAPI_FUNC(void) _Py_add_one_to_index_F(int nd, Py_ssize_t *index,
13884710c53dcad1ebf3755f3efb9e80ac24bd72a9b2darylm                                        const Py_ssize_t *shape);
13894710c53dcad1ebf3755f3efb9e80ac24bd72a9b2darylmPyAPI_FUNC(void) _Py_add_one_to_index_C(int nd, Py_ssize_t *index,
13904710c53dcad1ebf3755f3efb9e80ac24bd72a9b2darylm                                        const Py_ssize_t *shape);
13914710c53dcad1ebf3755f3efb9e80ac24bd72a9b2darylm
13924710c53dcad1ebf3755f3efb9e80ac24bd72a9b2darylm
13934710c53dcad1ebf3755f3efb9e80ac24bd72a9b2darylm#ifdef __cplusplus
13944710c53dcad1ebf3755f3efb9e80ac24bd72a9b2darylm}
13954710c53dcad1ebf3755f3efb9e80ac24bd72a9b2darylm#endif
13964710c53dcad1ebf3755f3efb9e80ac24bd72a9b2darylm#endif /* Py_ABSTRACTOBJECT_H */
1397