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
4bb5a33e
Commit
4bb5a33e
authored
Jul 03, 2017
by
Robert Bradshaw
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Conditionally use FastGil utility code.
parent
c986610a
Changes
4
Hide whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
22 additions
and
6 deletions
+22
-6
Cython/Compiler/Code.py
Cython/Compiler/Code.py
+16
-0
Cython/Compiler/ModuleNode.py
Cython/Compiler/ModuleNode.py
+0
-5
Cython/Compiler/Options.py
Cython/Compiler/Options.py
+1
-1
Cython/Utility/ModuleSetupCode.c
Cython/Utility/ModuleSetupCode.c
+5
-0
No files found.
Cython/Compiler/Code.py
View file @
4bb5a33e
...
@@ -2074,6 +2074,10 @@ class CCodeWriter(object):
...
@@ -2074,6 +2074,10 @@ class CCodeWriter(object):
"""
"""
self
.
globalstate
.
use_utility_code
(
self
.
globalstate
.
use_utility_code
(
UtilityCode
.
load_cached
(
"ForceInitThreads"
,
"ModuleSetupCode.c"
))
UtilityCode
.
load_cached
(
"ForceInitThreads"
,
"ModuleSetupCode.c"
))
if
self
.
globalstate
.
directives
[
'fast_gil'
]:
self
.
globalstate
.
use_utility_code
(
UtilityCode
.
load_cached
(
"FastGil"
,
"ModuleSetupCode.c"
))
else
:
self
.
globalstate
.
use_utility_code
(
UtilityCode
.
load_cached
(
"NoFastGil"
,
"ModuleSetupCode.c"
))
self
.
putln
(
"#ifdef WITH_THREAD"
)
self
.
putln
(
"#ifdef WITH_THREAD"
)
if
not
variable
:
if
not
variable
:
variable
=
'__pyx_gilstate_save'
variable
=
'__pyx_gilstate_save'
...
@@ -2086,6 +2090,10 @@ class CCodeWriter(object):
...
@@ -2086,6 +2090,10 @@ class CCodeWriter(object):
"""
"""
Releases the GIL, corresponds to `put_ensure_gil`.
Releases the GIL, corresponds to `put_ensure_gil`.
"""
"""
if
self
.
globalstate
.
directives
[
'fast_gil'
]:
self
.
globalstate
.
use_utility_code
(
UtilityCode
.
load_cached
(
"FastGil"
,
"ModuleSetupCode.c"
))
else
:
self
.
globalstate
.
use_utility_code
(
UtilityCode
.
load_cached
(
"NoFastGil"
,
"ModuleSetupCode.c"
))
if
not
variable
:
if
not
variable
:
variable
=
'__pyx_gilstate_save'
variable
=
'__pyx_gilstate_save'
self
.
putln
(
"#ifdef WITH_THREAD"
)
self
.
putln
(
"#ifdef WITH_THREAD"
)
...
@@ -2097,6 +2105,10 @@ class CCodeWriter(object):
...
@@ -2097,6 +2105,10 @@ class CCodeWriter(object):
Acquire the GIL. The thread's thread state must have been initialized
Acquire the GIL. The thread's thread state must have been initialized
by a previous `put_release_gil`
by a previous `put_release_gil`
"""
"""
if
self
.
globalstate
.
directives
[
'fast_gil'
]:
self
.
globalstate
.
use_utility_code
(
UtilityCode
.
load_cached
(
"FastGil"
,
"ModuleSetupCode.c"
))
else
:
self
.
globalstate
.
use_utility_code
(
UtilityCode
.
load_cached
(
"NoFastGil"
,
"ModuleSetupCode.c"
))
self
.
putln
(
"#ifdef WITH_THREAD"
)
self
.
putln
(
"#ifdef WITH_THREAD"
)
self
.
putln
(
"__Pyx_FastGIL_Forget();"
)
self
.
putln
(
"__Pyx_FastGIL_Forget();"
)
if
variable
:
if
variable
:
...
@@ -2106,6 +2118,10 @@ class CCodeWriter(object):
...
@@ -2106,6 +2118,10 @@ class CCodeWriter(object):
def
put_release_gil
(
self
,
variable
=
None
):
def
put_release_gil
(
self
,
variable
=
None
):
"Release the GIL, corresponds to `put_acquire_gil`."
"Release the GIL, corresponds to `put_acquire_gil`."
if
self
.
globalstate
.
directives
[
'fast_gil'
]:
self
.
globalstate
.
use_utility_code
(
UtilityCode
.
load_cached
(
"FastGil"
,
"ModuleSetupCode.c"
))
else
:
self
.
globalstate
.
use_utility_code
(
UtilityCode
.
load_cached
(
"NoFastGil"
,
"ModuleSetupCode.c"
))
self
.
putln
(
"#ifdef WITH_THREAD"
)
self
.
putln
(
"#ifdef WITH_THREAD"
)
self
.
putln
(
"PyThreadState *_save;"
)
self
.
putln
(
"PyThreadState *_save;"
)
self
.
putln
(
"Py_UNBLOCK_THREADS"
)
self
.
putln
(
"Py_UNBLOCK_THREADS"
)
...
...
Cython/Compiler/ModuleNode.py
View file @
4bb5a33e
...
@@ -719,10 +719,6 @@ class ModuleNode(Nodes.Node, Nodes.BlockNode):
...
@@ -719,10 +719,6 @@ class ModuleNode(Nodes.Node, Nodes.BlockNode):
if
has_np_pythran
(
env
):
if
has_np_pythran
(
env
):
env
.
use_utility_code
(
UtilityCode
.
load_cached
(
"PythranConversion"
,
"CppSupport.cpp"
))
env
.
use_utility_code
(
UtilityCode
.
load_cached
(
"PythranConversion"
,
"CppSupport.cpp"
))
if
env
.
directives
[
'fast_gil'
]:
env
.
use_utility_code
(
UtilityCode
.
load_cached
(
"FastGil"
,
"ModuleSetupCode.c"
))
else
:
env
.
use_utility_code
(
UtilityCode
.
load_cached
(
"NoFastGil"
,
"ModuleSetupCode.c"
))
def
generate_extern_c_macro_definition
(
self
,
code
):
def
generate_extern_c_macro_definition
(
self
,
code
):
name
=
Naming
.
extern_c_macro
name
=
Naming
.
extern_c_macro
...
@@ -2155,7 +2151,6 @@ class ModuleNode(Nodes.Node, Nodes.BlockNode):
...
@@ -2155,7 +2151,6 @@ class ModuleNode(Nodes.Node, Nodes.BlockNode):
code
.
putln
(
"%s = PyUnicode_FromStringAndSize(
\
"
\
"
, 0); %s"
%
(
code
.
putln
(
"%s = PyUnicode_FromStringAndSize(
\
"
\
"
, 0); %s"
%
(
Naming
.
empty_unicode
,
code
.
error_goto_if_null
(
Naming
.
empty_unicode
,
self
.
pos
)))
Naming
.
empty_unicode
,
code
.
error_goto_if_null
(
Naming
.
empty_unicode
,
self
.
pos
)))
code
.
putln
(
"__Pyx_FastGilFuncInit();"
);
for
ext_type
in
(
'CyFunction'
,
'FusedFunction'
,
'Coroutine'
,
'Generator'
,
'StopAsyncIteration'
):
for
ext_type
in
(
'CyFunction'
,
'FusedFunction'
,
'Coroutine'
,
'Generator'
,
'StopAsyncIteration'
):
code
.
putln
(
"#ifdef __Pyx_%s_USED"
%
ext_type
)
code
.
putln
(
"#ifdef __Pyx_%s_USED"
%
ext_type
)
code
.
put_error_if_neg
(
self
.
pos
,
"__pyx_%s_init()"
%
ext_type
)
code
.
put_error_if_neg
(
self
.
pos
,
"__pyx_%s_init()"
%
ext_type
)
...
...
Cython/Compiler/Options.py
View file @
4bb5a33e
...
@@ -176,7 +176,7 @@ _directive_defaults = {
...
@@ -176,7 +176,7 @@ _directive_defaults = {
'unraisable_tracebacks'
:
True
,
'unraisable_tracebacks'
:
True
,
'old_style_globals'
:
False
,
'old_style_globals'
:
False
,
'np_pythran'
:
False
,
'np_pythran'
:
False
,
'fast_gil'
:
Fals
e
,
# TODO(robertwb): Consider changing the default before releasing.
'fast_gil'
:
Tru
e
,
# TODO(robertwb): Consider changing the default before releasing.
# set __file__ and/or __path__ to known source/target path at import time (instead of not having them available)
# set __file__ and/or __path__ to known source/target path at import time (instead of not having them available)
'set_initial_path'
:
None
,
# SOURCEFILE or "/full/path/to/module"
'set_initial_path'
:
None
,
# SOURCEFILE or "/full/path/to/module"
...
...
Cython/Utility/ModuleSetupCode.c
View file @
4bb5a33e
...
@@ -864,6 +864,11 @@ static int __Pyx_RegisterCleanup(void) {
...
@@ -864,6 +864,11 @@ static int __Pyx_RegisterCleanup(void) {
}
}
#endif
#endif
/////////////// FastGil.init ///////////////
#ifdef WITH_THREAD
__Pyx_FastGilFuncInit
();
#endif
/////////////// NoFastGil.proto ///////////////
/////////////// NoFastGil.proto ///////////////
#define __Pyx_PyGILState_Ensure PyGILState_Ensure
#define __Pyx_PyGILState_Ensure PyGILState_Ensure
...
...
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