Number Protocol
===============
`int PyNumber_Check(PyObject *o)'
Returns `1' if the object O provides numeric protocols, and false
otherwise. This function always succeeds.
`PyObject* PyNumber_Add(PyObject *o1, PyObject *o2)'
Returns the result of adding O1 and O2, or `NULL' on failure.
This is the equivalent of the Python expression `O1 + O2'.
`PyObject* PyNumber_Subtract(PyObject *o1, PyObject *o2)'
Returns the result of subtracting O2 from O1, or `NULL' on
failure. This is the equivalent of the Python expression `O1 -
O2'.
`PyObject* PyNumber_Multiply(PyObject *o1, PyObject *o2)'
Returns the result of multiplying O1 and O2, or `NULL' on failure.
This is the equivalent of the Python expression `O1 * O2'.
`PyObject* PyNumber_Divide(PyObject *o1, PyObject *o2)'
Returns the result of dividing O1 by O2, or `NULL' on failure.
This is the equivalent of the Python expression `O1 / O2'.
`PyObject* PyNumber_Remainder(PyObject *o1, PyObject *o2)'
Returns the remainder of dividing O1 by O2, or `NULL' on failure.
This is the equivalent of the Python expression `O1 % O2'.
`PyObject* PyNumber_Divmod(PyObject *o1, PyObject *o2)'
See the built-in function `divmod()' . Returns `NULL' on failure.
This is the equivalent of the Python expression `divmod(O1, O2)'.
`PyObject* PyNumber_Power(PyObject *o1, PyObject *o2, PyObject *o3)'
See the built-in function `pow()' . Returns `NULL' on failure.
This is the equivalent of the Python expression `pow(O1, O2, O3)',
where O3 is optional. If O3 is to be ignored, pass `Py_None' in
its place (passing `NULL' for O3 would cause an illegal memory
access).
`PyObject* PyNumber_Negative(PyObject *o)'
Returns the negation of O on success, or `NULL' on failure. This
is the equivalent of the Python expression `-O'.
`PyObject* PyNumber_Positive(PyObject *o)'
Returns O on success, or `NULL' on failure. This is the
equivalent of the Python expression `+O'.
`PyObject* PyNumber_Absolute(PyObject *o)'
Returns the absolute value of O, or `NULL' on failure. This is
the equivalent of the Python expression `abs(O)'.
`PyObject* PyNumber_Invert(PyObject *o)'
Returns the bitwise negation of O on success, or `NULL' on
failure. This is the equivalent of the Python expression `~O'.
`PyObject* PyNumber_Lshift(PyObject *o1, PyObject *o2)'
Returns the result of left shifting O1 by O2 on success, or `NULL'
on failure. This is the equivalent of the Python expression `O1
<`<' O2'.
`PyObject* PyNumber_Rshift(PyObject *o1, PyObject *o2)'
Returns the result of right shifting O1 by O2 on success, or
`NULL' on failure. This is the equivalent of the Python
expression `O1 >`>' O2'.
`PyObject* PyNumber_And(PyObject *o1, PyObject *o2)'
Returns the "bitwise and" of O2 and O2 on success and `NULL' on
failure. This is the equivalent of the Python expression `O1 & O2'.
`PyObject* PyNumber_Xor(PyObject *o1, PyObject *o2)'
Returns the "bitwise exclusive or" of O1 by O2 on success, or
`NULL' on failure. This is the equivalent of the Python
expression `O1 ^ O2'.
`PyObject* PyNumber_Or(PyObject *o1, PyObject *o2)'
Returns the "bitwise or" of O1 and O2 on success, or `NULL' on
failure. This is the equivalent of the Python expression `O1 |
O2'.
`PyObject* PyNumber_InPlaceAdd(PyObject *o1, PyObject *o2)'
Returns the result of adding O1 and O2, or `NULL' on failure. The
operation is done _in-place_ when O1 supports it. This is the
equivalent of the Python expression `O1 += O2'.
`PyObject* PyNumber_InPlaceSubtract(PyObject *o1, PyObject *o2)'
Returns the result of subtracting O2 from O1, or `NULL' on
failure. The operation is done _in-place_ when O1 supports it.
This is the equivalent of the Python expression `O1 -= O2'.
`PyObject* PyNumber_InPlaceMultiply(PyObject *o1, PyObject *o2)'
Returns the result of multiplying O1 and O2, or `NULL' on failure.
The operation is done _in-place_ when O1 supports it. This is
the equivalent of the Python expression `O1 *= O2'.
`PyObject* PyNumber_InPlaceDivide(PyObject *o1, PyObject *o2)'
Returns the result of dividing O1 by O2, or `NULL' on failure.
The operation is done _in-place_ when O1 supports it. This is the
equivalent of the Python expression `O1 /= O2'.
`PyObject* PyNumber_InPlaceRemainder(PyObject *o1, PyObject *o2)'
Returns the remainder of dividing O1 by O2, or `NULL' on failure.
The operation is done _in-place_ when O1 supports it. This is the
equivalent of the Python expression `O1 %= O2'.
`PyObject* PyNumber_InPlacePower(PyObject *o1, PyObject *o2, PyObject *o3)'
See the built-in function `pow()' . Returns `NULL' on failure.
The operation is done _in-place_ when O1 supports it. This is the
equivalent of the Python expression `O1 **= O2' when o3 is
`Py_None', or an in-place variant of `pow(O1, O2, O3)' otherwise.
If O3 is to be ignored, pass `Py_None' in its place (passing
`NULL' for O3 would cause an illegal memory access).
`PyObject* PyNumber_InPlaceLshift(PyObject *o1, PyObject *o2)'
Returns the result of left shifting O1 by O2 on success, or `NULL'
on failure. The operation is done _in-place_ when O1 supports it.
This is the equivalent of the Python expression `O1 <`<=' O2'.
`PyObject* PyNumber_InPlaceRshift(PyObject *o1, PyObject *o2)'
Returns the result of right shifting O1 by O2 on success, or
`NULL' on failure. The operation is done _in-place_ when O1
supports it. This is the equivalent of the Python expression `O1
>`>=' O2'.
`PyObject* PyNumber_InPlaceAnd(PyObject *o1, PyObject *o2)'
Returns the "bitwise and" of O1 and O2 on success and `NULL' on
failure. The operation is done _in-place_ when O1 supports it.
This is the equivalent of the Python expression `O1 &= O2'.
`PyObject* PyNumber_InPlaceXor(PyObject *o1, PyObject *o2)'
Returns the "bitwise exclusive or" of O1 by O2 on success, or
`NULL' on failure. The operation is done _in-place_ when O1
supports it. This is the equivalent of the Python expression `O1
^= O2'.
`PyObject* PyNumber_InPlaceOr(PyObject *o1, PyObject *o2)'
Returns the "bitwise or" of O1 and O2 on success, or `NULL' on
failure. The operation is done _in-place_ when O1 supports it.
This is the equivalent of the Python expression `O1 |= O2'.
`int PyNumber_Coerce(PyObject **p1, PyObject **p2)'
This function takes the addresses of two variables of type
`PyObject*'. If the objects pointed to by `*P1' and `*P2' have
the same type, increment their reference count and return `0'
(success). If the objects can be converted to a common numeric
type, replace `*p1' and `*p2' by their converted value (with 'new'
reference counts), and return `0'. If no conversion is possible,
or if some other error occurs, return `-1' (failure) and don't
increment the reference counts. The call `PyNumber_Coerce(&o1,
&o2)' is equivalent to the Python statement `O1, O2 = coerce(O1,
O2)'.
`PyObject* PyNumber_Int(PyObject *o)'
Returns the O converted to an integer object on success, or `NULL'
on failure. This is the equivalent of the Python expression
`int(O)'.
`PyObject* PyNumber_Long(PyObject *o)'
Returns the O converted to a long integer object on success, or
`NULL' on failure. This is the equivalent of the Python
expression `long(O)'.
`PyObject* PyNumber_Float(PyObject *o)'
Returns the O converted to a float object on success, or `NULL' on
failure. This is the equivalent of the Python expression
`float(O)'.