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
Boxiang Sun
cython
Commits
5407899f
Commit
5407899f
authored
Sep 16, 2018
by
Stefan Behnel
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Support a direct "language_level" argument in "cython.inline()", and fix a test by using it.
parent
c8e6f375
Changes
3
Show whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
12 additions
and
4 deletions
+12
-4
CHANGES.rst
CHANGES.rst
+3
-0
Cython/Build/Inline.py
Cython/Build/Inline.py
+8
-3
tests/run/test_coroutines_pep492.pyx
tests/run/test_coroutines_pep492.pyx
+1
-1
No files found.
CHANGES.rst
View file @
5407899f
...
@@ -26,6 +26,9 @@ Features added
...
@@ -26,6 +26,9 @@ Features added
* ``@cython.nogil`` is supported as a C-function decorator in Python code.
* ``@cython.nogil`` is supported as a C-function decorator in Python code.
(Github issue #2557)
(Github issue #2557)
* ``cython.inline()`` supports a direct ``language_level`` keyword argument that
was previously only available via a directive.
* In CPython 3.6 and later, looking up globals in the module dict is almost
* In CPython 3.6 and later, looking up globals in the module dict is almost
as fast as looking up C globals.
as fast as looking up C globals.
(Github issue #2313)
(Github issue #2313)
...
...
Cython/Build/Inline.py
View file @
5407899f
...
@@ -139,7 +139,7 @@ def _populate_unbound(kwds, unbound_symbols, locals=None, globals=None):
...
@@ -139,7 +139,7 @@ def _populate_unbound(kwds, unbound_symbols, locals=None, globals=None):
def
cython_inline
(
code
,
get_type
=
unsafe_type
,
def
cython_inline
(
code
,
get_type
=
unsafe_type
,
lib_dir
=
os
.
path
.
join
(
get_cython_cache_dir
(),
'inline'
),
lib_dir
=
os
.
path
.
join
(
get_cython_cache_dir
(),
'inline'
),
cython_include_dirs
=
None
,
cython_compiler_directives
=
None
,
cython_include_dirs
=
None
,
cython_compiler_directives
=
None
,
force
=
False
,
quiet
=
False
,
locals
=
None
,
globals
=
None
,
**
kwds
):
force
=
False
,
quiet
=
False
,
locals
=
None
,
globals
=
None
,
language_level
=
None
,
**
kwds
):
if
get_type
is
None
:
if
get_type
is
None
:
get_type
=
lambda
x
:
'object'
get_type
=
lambda
x
:
'object'
...
@@ -171,6 +171,11 @@ def cython_inline(code, get_type=unsafe_type,
...
@@ -171,6 +171,11 @@ def cython_inline(code, get_type=unsafe_type,
if
not
quiet
:
if
not
quiet
:
# Parsing from strings not fully supported (e.g. cimports).
# Parsing from strings not fully supported (e.g. cimports).
print
(
"Could not parse code as a string (to extract unbound symbols)."
)
print
(
"Could not parse code as a string (to extract unbound symbols)."
)
cython_compiler_directives
=
dict
(
cython_compiler_directives
or
{})
if
language_level
is
not
None
:
cython_compiler_directives
[
'language_level'
]
=
language_level
cimports
=
[]
cimports
=
[]
for
name
,
arg
in
list
(
kwds
.
items
()):
for
name
,
arg
in
list
(
kwds
.
items
()):
if
arg
is
cython_module
:
if
arg
is
cython_module
:
...
@@ -178,7 +183,7 @@ def cython_inline(code, get_type=unsafe_type,
...
@@ -178,7 +183,7 @@ def cython_inline(code, get_type=unsafe_type,
del
kwds
[
name
]
del
kwds
[
name
]
arg_names
=
sorted
(
kwds
)
arg_names
=
sorted
(
kwds
)
arg_sigs
=
tuple
([(
get_type
(
kwds
[
arg
],
ctx
),
arg
)
for
arg
in
arg_names
])
arg_sigs
=
tuple
([(
get_type
(
kwds
[
arg
],
ctx
),
arg
)
for
arg
in
arg_names
])
key
=
orig_code
,
arg_sigs
,
sys
.
version_info
,
sys
.
executable
,
Cython
.
__version__
key
=
orig_code
,
arg_sigs
,
sys
.
version_info
,
sys
.
executable
,
language_level
,
Cython
.
__version__
module_name
=
"_cython_inline_"
+
hashlib
.
md5
(
_unicode
(
key
).
encode
(
'utf-8'
)).
hexdigest
()
module_name
=
"_cython_inline_"
+
hashlib
.
md5
(
_unicode
(
key
).
encode
(
'utf-8'
)).
hexdigest
()
if
module_name
in
sys
.
modules
:
if
module_name
in
sys
.
modules
:
...
@@ -238,7 +243,7 @@ def __invoke(%(params)s):
...
@@ -238,7 +243,7 @@ def __invoke(%(params)s):
build_extension.extensions = cythonize(
build_extension.extensions = cythonize(
[extension],
[extension],
include_path=cython_include_dirs or ['
.
'],
include_path=cython_include_dirs or ['
.
'],
compiler_directives=cython_compiler_directives
or {}
,
compiler_directives=cython_compiler_directives,
quiet=quiet)
quiet=quiet)
build_extension.build_temp = os.path.dirname(pyx_file)
build_extension.build_temp = os.path.dirname(pyx_file)
build_extension.build_lib = lib_dir
build_extension.build_lib = lib_dir
...
...
tests/run/test_coroutines_pep492.pyx
View file @
5407899f
...
@@ -76,7 +76,7 @@ def exec(code_string, l, g):
...
@@ -76,7 +76,7 @@ def exec(code_string, l, g):
old_stderr
=
sys
.
stderr
old_stderr
=
sys
.
stderr
try
:
try
:
sys
.
stderr
=
StringIO
()
sys
.
stderr
=
StringIO
()
ns
=
inline
(
code_string
,
locals
=
l
,
globals
=
g
,
lib_dir
=
os
.
path
.
dirname
(
__file__
))
ns
=
inline
(
code_string
,
locals
=
l
,
globals
=
g
,
lib_dir
=
os
.
path
.
dirname
(
__file__
)
,
language_level
=
3
)
finally
:
finally
:
sys
.
stderr
=
old_stderr
sys
.
stderr
=
old_stderr
g
.
update
(
ns
)
g
.
update
(
ns
)
...
...
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