Commit 8830bf2b authored by Stefan Behnel's avatar Stefan Behnel

Add the new "c_api_binop_methods" directive to the documentation.

parent ec99487b
......@@ -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.
......
......@@ -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
......
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