Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
C
cython
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
0
Merge Requests
0
Analytics
Analytics
Repository
Value Stream
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Commits
Issue Boards
Open sidebar
Gwenaël Samain
cython
Commits
4c461c93
Commit
4c461c93
authored
Oct 13, 2017
by
Stefan Behnel
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Link to the special method documentation in CPython from the Cython docs.
parent
244dd822
Changes
2
Show whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
25 additions
and
5 deletions
+25
-5
docs/src/reference/extension_types.rst
docs/src/reference/extension_types.rst
+4
-2
docs/src/userguide/special_methods.rst
docs/src/userguide/special_methods.rst
+21
-3
No files found.
docs/src/reference/extension_types.rst
View file @
4c461c93
...
...
@@ -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
...
...
docs/src/userguide/special_methods.rst
View file @
4c461c93
...
...
@@ -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 |
+=======================+=======================================+=============+=====================================================+
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment