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
2e72088e
Commit
2e72088e
authored
Sep 04, 2018
by
Alex Lubbock
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
cython_inline compiler directives support
parent
b1960185
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
17 additions
and
3 deletions
+17
-3
Cython/Build/Inline.py
Cython/Build/Inline.py
+9
-3
tests/run/test_fstring.pyx
tests/run/test_fstring.pyx
+8
-0
No files found.
Cython/Build/Inline.py
View file @
2e72088e
...
@@ -136,8 +136,10 @@ def _populate_unbound(kwds, unbound_symbols, locals=None, globals=None):
...
@@ -136,8 +136,10 @@ def _populate_unbound(kwds, unbound_symbols, locals=None, globals=None):
else
:
else
:
print
(
"Couldn't find %r"
%
symbol
)
print
(
"Couldn't find %r"
%
symbol
)
def
cython_inline
(
code
,
get_type
=
unsafe_type
,
lib_dir
=
os
.
path
.
join
(
get_cython_cache_dir
(),
'inline'
),
def
cython_inline
(
code
,
get_type
=
unsafe_type
,
cython_include_dirs
=
None
,
force
=
False
,
quiet
=
False
,
locals
=
None
,
globals
=
None
,
**
kwds
):
lib_dir
=
os
.
path
.
join
(
get_cython_cache_dir
(),
'inline'
),
cython_include_dirs
=
None
,
cython_compiler_directives
=
None
,
force
=
False
,
quiet
=
False
,
locals
=
None
,
globals
=
None
,
**
kwds
):
if
get_type
is
None
:
if
get_type
is
None
:
get_type
=
lambda
x
:
'object'
get_type
=
lambda
x
:
'object'
...
@@ -233,7 +235,11 @@ def __invoke(%(params)s):
...
@@ -233,7 +235,11 @@ def __invoke(%(params)s):
extra_compile_args = cflags)
extra_compile_args = cflags)
if build_extension is None:
if build_extension is None:
build_extension = _get_build_extension()
build_extension = _get_build_extension()
build_extension.extensions = cythonize([extension], include_path=cython_include_dirs or ['
.
'], quiet=quiet)
build_extension.extensions = cythonize(
[extension],
include_path=cython_include_dirs or ['
.
'],
compiler_directives=cython_compiler_directives or {},
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
build_extension.run()
build_extension.run()
...
...
tests/run/test_fstring.pyx
View file @
2e72088e
...
@@ -849,6 +849,14 @@ f'{a * x()}'"""
...
@@ -849,6 +849,14 @@ f'{a * x()}'"""
self.assertEqual(f'
{
d
[
"foo"
]
}
', '
bar
')
self.assertEqual(f'
{
d
[
"foo"
]
}
', '
bar
')
self.assertEqual(f"
{
d
[
'foo'
]
}
", 'bar')
self.assertEqual(f"
{
d
[
'foo'
]
}
", 'bar')
def test_inline_compiler_directives(self):
self.assertEqual(
cy_eval('sum(x)',
x=[1,2,3],
cython_compiler_directives=
{
'boundscheck'
:
False
}
),
6
)
def
__test_backslash_char
(
self
):
def
__test_backslash_char
(
self
):
# Check eval of a backslash followed by a control char.
# Check eval of a backslash followed by a control char.
# See bpo-30682: this used to raise an assert in pydebug mode.
# See bpo-30682: this used to raise an assert in pydebug mode.
...
...
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