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
4493184c
Commit
4493184c
authored
Sep 11, 2015
by
Stefan Behnel
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
docs: clarify behaviour of 'nogil' function annotation
parent
e61da2eb
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
12 additions
and
9 deletions
+12
-9
docs/src/userguide/external_C_code.rst
docs/src/userguide/external_C_code.rst
+12
-9
No files found.
docs/src/userguide/external_C_code.rst
View file @
4493184c
...
@@ -531,15 +531,18 @@ declare that it is safe to call without the GIL.::
...
@@ -531,15 +531,18 @@ declare that it is safe to call without the GIL.::
cdef void my_gil_free_func(int spam) nogil:
cdef void my_gil_free_func(int spam) nogil:
...
...
If you are implementing such a function in Cython, it cannot have any Python
When you implement such a function in Cython, it cannot have any Python
arguments, Python local variables, or Python return type, and cannot
arguments or Python object return type. Furthermore, any operation
manipulate Python objects in any way or call any function that does so without
that involves Python objects (including calling Python functions) must
acquiring the GIL first. Some of these restrictions are currently checked by
explicitly acquire the GIL first, e.g. by using a ``with gil`` block
Cython, but not all. It is possible that more stringent checking will be
or by calling a function that has been defined ``with gil``. These
performed in the future.
restrictions are checked by Cython and you will get a compile error
if it finds any Python interaction inside of a ``nogil`` code section.
.. NOTE:: This declaration declares that it is safe to call the function without the GIL,
it does not in itself release the GIL.
.. NOTE:: The ``nogil`` function annotation declares that it is safe
to call the function without the GIL. It is perfectly allowed
to execute it while holding the GIL. The function does not in
itself release the GIL if it is held by the caller.
Declaring a function ``with gil`` (i.e. as acquiring the GIL on entry) also
Declaring a function ``with gil`` (i.e. as acquiring the GIL on entry) also
implicitly makes its signature :keyword:`nogil`.
implicitly makes its signature :keyword:`nogil`.
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