summaryrefslogtreecommitdiffstats
path: root/Doc/c-api/number.rst
diff options
context:
space:
mode:
authorGeorg Brandl <georg@python.org>2010-10-06 10:11:56 (GMT)
committerGeorg Brandl <georg@python.org>2010-10-06 10:11:56 (GMT)
commit60203b41b03d03361754d264543d5fbe6259eb25 (patch)
tree005d0d6be6437244ae360ebc0d65fa7b149a8093 /Doc/c-api/number.rst
parent64a41edb039afee683d69bd6f72e3709ff11bd93 (diff)
downloadcpython-60203b41b03d03361754d264543d5fbe6259eb25.zip
cpython-60203b41b03d03361754d264543d5fbe6259eb25.tar.gz
cpython-60203b41b03d03361754d264543d5fbe6259eb25.tar.bz2
Migrate to Sphinx 1.0 C language constructs.
Diffstat (limited to 'Doc/c-api/number.rst')
-rw-r--r--Doc/c-api/number.rst80
1 files changed, 40 insertions, 40 deletions
diff --git a/Doc/c-api/number.rst b/Doc/c-api/number.rst
index d79b9fb..eda722d 100644
--- a/Doc/c-api/number.rst
+++ b/Doc/c-api/number.rst
@@ -6,37 +6,37 @@ Number Protocol
===============
-.. cfunction:: int PyNumber_Check(PyObject *o)
+.. c:function:: int PyNumber_Check(PyObject *o)
Returns ``1`` if the object *o* provides numeric protocols, and false otherwise.
This function always succeeds.
-.. cfunction:: PyObject* PyNumber_Add(PyObject *o1, PyObject *o2)
+.. c:function:: 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``.
-.. cfunction:: PyObject* PyNumber_Subtract(PyObject *o1, PyObject *o2)
+.. c:function:: 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``.
-.. cfunction:: PyObject* PyNumber_Multiply(PyObject *o1, PyObject *o2)
+.. c:function:: 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``.
-.. cfunction:: PyObject* PyNumber_FloorDivide(PyObject *o1, PyObject *o2)
+.. c:function:: PyObject* PyNumber_FloorDivide(PyObject *o1, PyObject *o2)
Return the floor of *o1* divided by *o2*, or *NULL* on failure. This is
equivalent to the "classic" division of integers.
-.. cfunction:: PyObject* PyNumber_TrueDivide(PyObject *o1, PyObject *o2)
+.. c:function:: PyObject* PyNumber_TrueDivide(PyObject *o1, PyObject *o2)
Return a reasonable approximation for the mathematical value of *o1* divided by
*o2*, or *NULL* on failure. The return value is "approximate" because binary
@@ -45,13 +45,13 @@ Number Protocol
passed two integers.
-.. cfunction:: PyObject* PyNumber_Remainder(PyObject *o1, PyObject *o2)
+.. c:function:: 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``.
-.. cfunction:: PyObject* PyNumber_Divmod(PyObject *o1, PyObject *o2)
+.. c:function:: PyObject* PyNumber_Divmod(PyObject *o1, PyObject *o2)
.. index:: builtin: divmod
@@ -59,29 +59,29 @@ Number Protocol
the equivalent of the Python expression ``divmod(o1, o2)``.
-.. cfunction:: PyObject* PyNumber_Power(PyObject *o1, PyObject *o2, PyObject *o3)
+.. c:function:: PyObject* PyNumber_Power(PyObject *o1, PyObject *o2, PyObject *o3)
.. index:: builtin: pow
See the built-in function :func:`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 :cdata:`Py_None` in its place (passing *NULL* for
+ If *o3* is to be ignored, pass :c:data:`Py_None` in its place (passing *NULL* for
*o3* would cause an illegal memory access).
-.. cfunction:: PyObject* PyNumber_Negative(PyObject *o)
+.. c:function:: 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``.
-.. cfunction:: PyObject* PyNumber_Positive(PyObject *o)
+.. c:function:: PyObject* PyNumber_Positive(PyObject *o)
Returns *o* on success, or *NULL* on failure. This is the equivalent of the
Python expression ``+o``.
-.. cfunction:: PyObject* PyNumber_Absolute(PyObject *o)
+.. c:function:: PyObject* PyNumber_Absolute(PyObject *o)
.. index:: builtin: abs
@@ -89,71 +89,71 @@ Number Protocol
of the Python expression ``abs(o)``.
-.. cfunction:: PyObject* PyNumber_Invert(PyObject *o)
+.. c:function:: 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``.
-.. cfunction:: PyObject* PyNumber_Lshift(PyObject *o1, PyObject *o2)
+.. c:function:: 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``.
-.. cfunction:: PyObject* PyNumber_Rshift(PyObject *o1, PyObject *o2)
+.. c:function:: 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``.
-.. cfunction:: PyObject* PyNumber_And(PyObject *o1, PyObject *o2)
+.. c:function:: PyObject* PyNumber_And(PyObject *o1, PyObject *o2)
Returns the "bitwise and" of *o1* and *o2* on success and *NULL* on failure.
This is the equivalent of the Python expression ``o1 & o2``.
-.. cfunction:: PyObject* PyNumber_Xor(PyObject *o1, PyObject *o2)
+.. c:function:: 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``.
-.. cfunction:: PyObject* PyNumber_Or(PyObject *o1, PyObject *o2)
+.. c:function:: 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``.
-.. cfunction:: PyObject* PyNumber_InPlaceAdd(PyObject *o1, PyObject *o2)
+.. c:function:: 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
statement ``o1 += o2``.
-.. cfunction:: PyObject* PyNumber_InPlaceSubtract(PyObject *o1, PyObject *o2)
+.. c:function:: 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 statement ``o1 -= o2``.
-.. cfunction:: PyObject* PyNumber_InPlaceMultiply(PyObject *o1, PyObject *o2)
+.. c:function:: 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 statement ``o1 *= o2``.
-.. cfunction:: PyObject* PyNumber_InPlaceFloorDivide(PyObject *o1, PyObject *o2)
+.. c:function:: PyObject* PyNumber_InPlaceFloorDivide(PyObject *o1, PyObject *o2)
Returns the mathematical floor 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 statement ``o1 //= o2``.
-.. cfunction:: PyObject* PyNumber_InPlaceTrueDivide(PyObject *o1, PyObject *o2)
+.. c:function:: PyObject* PyNumber_InPlaceTrueDivide(PyObject *o1, PyObject *o2)
Return a reasonable approximation for the mathematical value of *o1* divided by
*o2*, or *NULL* on failure. The return value is "approximate" because binary
@@ -162,60 +162,60 @@ Number Protocol
passed two integers. The operation is done *in-place* when *o1* supports it.
-.. cfunction:: PyObject* PyNumber_InPlaceRemainder(PyObject *o1, PyObject *o2)
+.. c:function:: 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 statement ``o1 %= o2``.
-.. cfunction:: PyObject* PyNumber_InPlacePower(PyObject *o1, PyObject *o2, PyObject *o3)
+.. c:function:: PyObject* PyNumber_InPlacePower(PyObject *o1, PyObject *o2, PyObject *o3)
.. index:: builtin: pow
See the built-in function :func:`pow`. Returns *NULL* on failure. The operation
is done *in-place* when *o1* supports it. This is the equivalent of the Python
- statement ``o1 **= o2`` when o3 is :cdata:`Py_None`, or an in-place variant of
- ``pow(o1, o2, o3)`` otherwise. If *o3* is to be ignored, pass :cdata:`Py_None`
+ statement ``o1 **= o2`` when o3 is :c:data:`Py_None`, or an in-place variant of
+ ``pow(o1, o2, o3)`` otherwise. If *o3* is to be ignored, pass :c:data:`Py_None`
in its place (passing *NULL* for *o3* would cause an illegal memory access).
-.. cfunction:: PyObject* PyNumber_InPlaceLshift(PyObject *o1, PyObject *o2)
+.. c:function:: 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 statement ``o1 <<= o2``.
-.. cfunction:: PyObject* PyNumber_InPlaceRshift(PyObject *o1, PyObject *o2)
+.. c:function:: 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 statement ``o1 >>= o2``.
-.. cfunction:: PyObject* PyNumber_InPlaceAnd(PyObject *o1, PyObject *o2)
+.. c:function:: 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 statement ``o1 &= o2``.
-.. cfunction:: PyObject* PyNumber_InPlaceXor(PyObject *o1, PyObject *o2)
+.. c:function:: 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 statement ``o1 ^= o2``.
-.. cfunction:: PyObject* PyNumber_InPlaceOr(PyObject *o1, PyObject *o2)
+.. c:function:: 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 statement ``o1 |= o2``.
-.. cfunction:: PyObject* PyNumber_Long(PyObject *o)
+.. c:function:: PyObject* PyNumber_Long(PyObject *o)
.. index:: builtin: int
@@ -223,7 +223,7 @@ Number Protocol
failure. This is the equivalent of the Python expression ``int(o)``.
-.. cfunction:: PyObject* PyNumber_Float(PyObject *o)
+.. c:function:: PyObject* PyNumber_Float(PyObject *o)
.. index:: builtin: float
@@ -231,22 +231,22 @@ Number Protocol
This is the equivalent of the Python expression ``float(o)``.
-.. cfunction:: PyObject* PyNumber_Index(PyObject *o)
+.. c:function:: PyObject* PyNumber_Index(PyObject *o)
Returns the *o* converted to a Python int on success or *NULL* with a
:exc:`TypeError` exception raised on failure.
-.. cfunction:: PyObject* PyNumber_ToBase(PyObject *n, int base)
+.. c:function:: PyObject* PyNumber_ToBase(PyObject *n, int base)
Returns the integer *n* converted to *base* as a string with a base
marker of ``'0b'``, ``'0o'``, or ``'0x'`` if applicable. When
*base* is not 2, 8, 10, or 16, the format is ``'x#num'`` where x is the
base. If *n* is not an int object, it is converted with
- :cfunc:`PyNumber_Index` first.
+ :c:func:`PyNumber_Index` first.
-.. cfunction:: Py_ssize_t PyNumber_AsSsize_t(PyObject *o, PyObject *exc)
+.. c:function:: Py_ssize_t PyNumber_AsSsize_t(PyObject *o, PyObject *exc)
Returns *o* converted to a Py_ssize_t value if *o* can be interpreted as an
integer. If *o* can be converted to a Python int but the attempt to
@@ -257,7 +257,7 @@ Number Protocol
integer or *PY_SSIZE_T_MAX* for a positive integer.
-.. cfunction:: int PyIndex_Check(PyObject *o)
+.. c:function:: int PyIndex_Check(PyObject *o)
Returns True if *o* is an index integer (has the nb_index slot of the
tp_as_number structure filled in).