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
80638c1a
Commit
80638c1a
authored
Apr 23, 2014
by
Robert Bradshaw
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Let cython.inline return all defined variables by default.
parent
87049841
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
16 additions
and
5 deletions
+16
-5
Cython/Build/Inline.py
Cython/Build/Inline.py
+8
-4
Cython/Build/Tests/TestInline.py
Cython/Build/Tests/TestInline.py
+8
-1
No files found.
Cython/Build/Inline.py
View file @
80638c1a
...
...
@@ -150,10 +150,10 @@ def cython_inline(code,
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__
module_name
=
"_cython_inline_"
+
hashlib
.
md5
(
str
(
key
).
encode
(
'utf-8'
)).
hexdigest
()
if
module_name
in
sys
.
modules
:
module
=
sys
.
modules
[
module_name
]
else
:
build_extension
=
None
if
cython_inline
.
so_ext
is
None
:
...
...
@@ -185,12 +185,16 @@ def cython_inline(code,
%(cimports)s
def __invoke(%(params)s):
%(func_body)s
""" % {'
cimports
': '
\
n
'.join(cimports), '
module_body
': module_body, '
params
': params, '
func_body
': func_body }
return locals()
""" % {'
cimports
': '
\
n
'.join(cimports),
'
module_body
': module_body,
'
params
': params,
'
func_body
': func_body }
for key, value in literals.items():
module_code = module_code.replace(key, value)
pyx_file = os.path.join(lib_dir, module_name + '
.
pyx
')
fh = open(pyx_file, '
w
')
try:
try:
fh.write(module_code)
finally:
fh.close()
...
...
Cython/Build/Tests/TestInline.py
View file @
80638c1a
...
...
@@ -40,7 +40,14 @@ class TestInline(CythonTest):
def
test_globals
(
self
):
self
.
assertEquals
(
inline
(
"return global_value + 1"
,
**
self
.
test_kwds
),
global_value
+
1
)
def
test_pure
(
self
):
def
test_no_return
(
self
):
self
.
assertEquals
(
inline
(
"""
a = 1
cdef double b = 2
cdef c = []
"""
),
dict
(
a
=
1
,
b
=
2.0
,
c
=
[]))
def
test_pure
(
self
):
import
cython
as
cy
b
=
inline
(
"""
b = cy.declare(float, a)
...
...
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