summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorStefan Behnel <stefan_ml@behnel.de>2020-07-09 14:29:34 +0200
committerStefan Behnel <stefan_ml@behnel.de>2020-07-09 14:29:34 +0200
commit8830bf2b102996e3dda97e83fc3ef4efe368bdc6 (patch)
treec02bafb282816965c9cbeea0ad0fe257a65bbee9
parentec99487becc3a4a4f3bbd83be0bc31f027c8e11e (diff)
downloadcython-8830bf2b102996e3dda97e83fc3ef4efe368bdc6.tar.gz
Add the new "c_api_binop_methods" directive to the documentation.
-rw-r--r--docs/src/userguide/source_files_and_compilation.rst7
-rw-r--r--docs/src/userguide/special_methods.rst3
2 files changed, 10 insertions, 0 deletions
diff --git a/docs/src/userguide/source_files_and_compilation.rst b/docs/src/userguide/source_files_and_compilation.rst
index 100bd767c..bc3b08677 100644
--- a/docs/src/userguide/source_files_and_compilation.rst
+++ b/docs/src/userguide/source_files_and_compilation.rst
@@ -825,6 +825,13 @@ Cython code. Here is the list of currently supported directives:
``METH_NOARGS`` and ``METH_O`` signatures provide slightly faster
calling conventions but disallow the use of keywords.
+``c_api_binop_methods`` (True / False)
+ When enabled, makes the special binary operator methods (``__add__``, etc.)
+ behave according to the low-level C-API slot semantics, i.e. only a single
+ method implements both the normal and reversed operator. This used to be
+ the default in Cython 0.x and was now replaced by Python semantics, i.e. the
+ default in Cython 3.x and later is ``False``.
+
``profile`` (True / False)
Write hooks for Python profilers into the compiled C code. Default
is False.
diff --git a/docs/src/userguide/special_methods.rst b/docs/src/userguide/special_methods.rst
index c3cad40a2..9b59fe738 100644
--- a/docs/src/userguide/special_methods.rst
+++ b/docs/src/userguide/special_methods.rst
@@ -148,6 +148,9 @@ with ``self`` as first argument and will be ignored by older Cython versions, wh
Cython 3.x and later will only call the normal method with the expected argument order,
and otherwise call the reversed method instead.
+Alternatively, the old Cython 0.x (or native C-API) behaviour is still available with
+the directive ``c_api_binop_methods=True``.
+
If you can't handle the combination of types you've been given, you should return
`NotImplemented`. This will let Python's operator implementation first try to apply
the reversed operator to the second operand, and failing that as well, report an