Commit 4c461c93 authored by Stefan Behnel's avatar Stefan Behnel

Link to the special method documentation in CPython from the Cython docs.

parent 244dd822
......@@ -276,8 +276,10 @@ Arithmetic Methods
Rich Comparisons
================
* Starting with Cython 0.27, the Python special methods ``__eq__``, ``__lt__``, etc. can be implemented.
In previous versions, ``__richcmp__`` was the only way to implement rich comparisons.
* Starting with Cython 0.27, the Python
`special methods <https://docs.python.org/3/reference/datamodel.html#basic-customization>`_
``__eq__``, ``__lt__``, etc. can be implemented. In previous versions, ``__richcmp__`` was
the only way to implement rich comparisons.
* A single special method called ``__richcmp__()`` can be used to implement all the individual
rich compare, special method types.
* ``__richcmp__()`` takes an integer argument, indicating which operation is to be performed
......
......@@ -127,9 +127,11 @@ take `self` as the first argument.
Rich comparisons
-----------------
Starting with Cython 0.27, the Python special methods :meth:``__eq__``, :meth:``__lt__``, etc.
can be implemented. In previous versions, :meth:``__richcmp__`` was the only way to implement
rich comparisons. It takes an integer indicating which operation is to be performed, as follows:
Starting with Cython 0.27, the Python
`special methods <https://docs.python.org/3/reference/datamodel.html#basic-customization>`_
:meth:``__eq__``, :meth:``__lt__``, etc. can be implemented. In previous versions,
:meth:``__richcmp__`` was the only way to implement rich comparisons. It takes an integer
indicating which operation is to be performed, as follows:
+-----+-----+-------+
| < | 0 | Py_LT |
......@@ -170,6 +172,8 @@ declare different types, conversions will be performed as necessary.
General
^^^^^^^
https://docs.python.org/3/reference/datamodel.html#special-method-names
+-----------------------+---------------------------------------+-------------+-----------------------------------------------------+
| Name | Parameters | Return type | Description |
+=======================+=======================================+=============+=====================================================+
......@@ -203,6 +207,8 @@ General
Rich comparison operators
^^^^^^^^^^^^^^^^^^^^^^^^^
https://docs.python.org/3/reference/datamodel.html#basic-customization
+-----------------------+---------------------------------------+-------------+-----------------------------------------------------+
| __richcmp__ |x, y, int op | object | Rich comparison (no direct Python equivalent) |
+-----------------------+---------------------------------------+-------------+-----------------------------------------------------+
......@@ -222,6 +228,8 @@ Rich comparison operators
Arithmetic operators
^^^^^^^^^^^^^^^^^^^^
https://docs.python.org/3/reference/datamodel.html#emulating-numeric-types
+-----------------------+---------------------------------------+-------------+-----------------------------------------------------+
| Name | Parameters | Return type | Description |
+=======================+=======================================+=============+=====================================================+
......@@ -267,6 +275,8 @@ Arithmetic operators
Numeric conversions
^^^^^^^^^^^^^^^^^^^
https://docs.python.org/3/reference/datamodel.html#emulating-numeric-types
+-----------------------+---------------------------------------+-------------+-----------------------------------------------------+
| Name | Parameters | Return type | Description |
+=======================+=======================================+=============+=====================================================+
......@@ -286,6 +296,8 @@ Numeric conversions
In-place arithmetic operators
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
https://docs.python.org/3/reference/datamodel.html#emulating-numeric-types
+-----------------------+---------------------------------------+-------------+-----------------------------------------------------+
| Name | Parameters | Return type | Description |
+=======================+=======================================+=============+=====================================================+
......@@ -319,6 +331,8 @@ In-place arithmetic operators
Sequences and mappings
^^^^^^^^^^^^^^^^^^^^^^
https://docs.python.org/3/reference/datamodel.html#emulating-container-types
+-----------------------+---------------------------------------+-------------+-----------------------------------------------------+
| Name | Parameters | Return type | Description |
+=======================+=======================================+=============+=====================================================+
......@@ -342,6 +356,8 @@ Sequences and mappings
Iterators
^^^^^^^^^
https://docs.python.org/3/reference/datamodel.html#emulating-container-types
+-----------------------+---------------------------------------+-------------+-----------------------------------------------------+
| Name | Parameters | Return type | Description |
+=======================+=======================================+=============+=====================================================+
......@@ -377,6 +393,8 @@ Buffer interface [legacy] (no Python equivalents - see note 1)
Descriptor objects (see note 2)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
https://docs.python.org/3/reference/datamodel.html#emulating-container-types
+-----------------------+---------------------------------------+-------------+-----------------------------------------------------+
| Name | Parameters | Return type | Description |
+=======================+=======================================+=============+=====================================================+
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment