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
Labels
Merge Requests
0
Merge Requests
0
Analytics
Analytics
Repository
Value Stream
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Commits
Open sidebar
nexedi
cython
Commits
8830bf2b
Commit
8830bf2b
authored
Jul 09, 2020
by
Stefan Behnel
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Add the new "c_api_binop_methods" directive to the documentation.
parent
ec99487b
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
10 additions
and
0 deletions
+10
-0
docs/src/userguide/source_files_and_compilation.rst
docs/src/userguide/source_files_and_compilation.rst
+7
-0
docs/src/userguide/special_methods.rst
docs/src/userguide/special_methods.rst
+3
-0
No files found.
docs/src/userguide/source_files_and_compilation.rst
View file @
8830bf2b
...
...
@@ -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.
...
...
docs/src/userguide/special_methods.rst
View file @
8830bf2b
...
...
@@ -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
...
...
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