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
Kirill Smelkov
cython
Commits
d6aa0e99
Commit
d6aa0e99
authored
Nov 14, 2015
by
Stefan Behnel
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
avoid mutable default arguments (original patch by Rémy Léone)
parent
eaf2ce5d
Changes
7
Hide whitespace changes
Inline
Side-by-side
Showing
7 changed files
with
49 additions
and
23 deletions
+49
-23
Cython/Build/Dependencies.py
Cython/Build/Dependencies.py
+6
-2
Cython/Build/Inline.py
Cython/Build/Inline.py
+5
-9
Cython/Compiler/Nodes.py
Cython/Compiler/Nodes.py
+3
-1
Cython/Compiler/TreeFragment.py
Cython/Compiler/TreeFragment.py
+16
-4
Cython/TestUtils.py
Cython/TestUtils.py
+10
-3
pyximport/pyxbuild.py
pyximport/pyxbuild.py
+6
-3
pyximport/pyximport.py
pyximport/pyximport.py
+3
-1
No files found.
Cython/Build/Dependencies.py
View file @
d6aa0e99
...
...
@@ -625,8 +625,10 @@ def create_dependency_tree(ctx=None, quiet=False):
# This may be useful for advanced users?
def
create_extension_list
(
patterns
,
exclude
=
[]
,
ctx
=
None
,
aliases
=
None
,
quiet
=
False
,
language
=
None
,
def
create_extension_list
(
patterns
,
exclude
=
None
,
ctx
=
None
,
aliases
=
None
,
quiet
=
False
,
language
=
None
,
exclude_failures
=
False
):
if
exclude
is
None
:
exclude
=
[]
if
not
isinstance
(
patterns
,
(
list
,
tuple
)):
patterns
=
[
patterns
]
explicit_modules
=
set
([
m
.
name
for
m
in
patterns
if
isinstance
(
m
,
Extension
)])
...
...
@@ -725,7 +727,7 @@ def create_extension_list(patterns, exclude=[], ctx=None, aliases=None, quiet=Fa
# This is the user-exposed entry point.
def
cythonize
(
module_list
,
exclude
=
[]
,
nthreads
=
0
,
aliases
=
None
,
quiet
=
False
,
force
=
False
,
language
=
None
,
def
cythonize
(
module_list
,
exclude
=
None
,
nthreads
=
0
,
aliases
=
None
,
quiet
=
False
,
force
=
False
,
language
=
None
,
exclude_failures
=
False
,
**
options
):
"""
Compile a set of source modules into C/C++ files and return a list of distutils
...
...
@@ -753,6 +755,8 @@ def cythonize(module_list, exclude=[], nthreads=0, aliases=None, quiet=False, fo
Additional compilation options can be passed as keyword arguments.
"""
if
exclude
is
None
:
exclude
=
[]
if
'include_path'
not
in
options
:
options
[
'include_path'
]
=
[
'.'
]
if
'common_utility_include_dir'
in
options
:
...
...
Cython/Build/Inline.py
View file @
d6aa0e99
...
...
@@ -116,15 +116,11 @@ def _get_build_extension():
def
_create_context
(
cython_include_dirs
):
return
Context
(
list
(
cython_include_dirs
),
default_options
)
def
cython_inline
(
code
,
get_type
=
unsafe_type
,
lib_dir
=
os
.
path
.
join
(
get_cython_cache_dir
(),
'inline'
),
cython_include_dirs
=
[
'.'
],
force
=
False
,
quiet
=
False
,
locals
=
None
,
globals
=
None
,
**
kwds
):
def
cython_inline
(
code
,
get_type
=
unsafe_type
,
lib_dir
=
os
.
path
.
join
(
get_cython_cache_dir
(),
'inline'
),
cython_include_dirs
=
None
,
force
=
False
,
quiet
=
False
,
locals
=
None
,
globals
=
None
,
**
kwds
):
if
cython_include_dirs
is
None
:
cython_include_dirs
=
[
'.'
]
if
get_type
is
None
:
get_type
=
lambda
x
:
'object'
code
=
to_unicode
(
code
)
...
...
Cython/Compiler/Nodes.py
View file @
d6aa0e99
...
...
@@ -649,7 +649,9 @@ class CFuncDeclaratorNode(CDeclaratorNode):
else
:
return
None
def
analyse
(
self
,
return_type
,
env
,
nonempty
=
0
,
directive_locals
=
{}):
def
analyse
(
self
,
return_type
,
env
,
nonempty
=
0
,
directive_locals
=
None
):
if
directive_locals
is
None
:
directive_locals
=
{}
if
nonempty
:
nonempty
-=
1
func_type_args
=
[]
...
...
Cython/Compiler/TreeFragment.py
View file @
d6aa0e99
...
...
@@ -39,7 +39,7 @@ class StringParseContext(Main.Context):
return
ModuleScope
(
module_name
,
parent_module
=
None
,
context
=
self
)
def
parse_from_strings
(
name
,
code
,
pxds
=
{}
,
level
=
None
,
initial_pos
=
None
,
def
parse_from_strings
(
name
,
code
,
pxds
=
None
,
level
=
None
,
initial_pos
=
None
,
context
=
None
,
allow_struct_enum_decorator
=
False
):
"""
Utility method to parse a (unicode) string of code. This is mostly
...
...
@@ -215,9 +215,16 @@ def strip_common_indent(lines):
class
TreeFragment
(
object
):
def
__init__
(
self
,
code
,
name
=
None
,
pxds
=
{},
temps
=
[],
pipeline
=
[],
level
=
None
,
initial_pos
=
None
):
def
__init__
(
self
,
code
,
name
=
None
,
pxds
=
None
,
temps
=
None
,
pipeline
=
None
,
level
=
None
,
initial_pos
=
None
):
if
pxds
is
None
:
pxds
=
{}
if
temps
is
None
:
temps
=
[]
if
pipeline
is
None
:
pipeline
=
[]
if
not
name
:
name
=
"(tree fragment)"
if
isinstance
(
code
,
_unicode
):
def
fmt
(
x
):
return
u"
\
n
"
.
join
(
strip_common_indent
(
x
.
split
(
u"
\
n
"
)))
...
...
@@ -236,7 +243,8 @@ class TreeFragment(object):
t
=
transform
(
t
)
self
.
root
=
t
elif
isinstance
(
code
,
Node
):
if
pxds
!=
{}:
raise
NotImplementedError
()
if
pxds
:
raise
NotImplementedError
()
self
.
root
=
code
else
:
raise
ValueError
(
"Unrecognized code format (accepts unicode and Node)"
)
...
...
@@ -245,7 +253,11 @@ class TreeFragment(object):
def
copy
(
self
):
return
copy_code_tree
(
self
.
root
)
def
substitute
(
self
,
nodes
=
{},
temps
=
[],
pos
=
None
):
def
substitute
(
self
,
nodes
=
None
,
temps
=
None
,
pos
=
None
):
if
nodes
is
None
:
nodes
=
{}
if
temps
is
None
:
temps
=
[]
return
TemplateTransform
()(
self
.
root
,
substitutions
=
nodes
,
temps
=
self
.
temps
+
temps
,
pos
=
pos
)
...
...
Cython/TestUtils.py
View file @
d6aa0e99
...
...
@@ -84,10 +84,15 @@ class CythonTest(unittest.TestCase):
self
.
assertNotEqual
(
TreePath
.
find_first
(
result_tree
,
path
),
None
,
"Path '%s' not found in result tree"
%
path
)
def
fragment
(
self
,
code
,
pxds
=
{},
pipeline
=
[]
):
def
fragment
(
self
,
code
,
pxds
=
None
,
pipeline
=
None
):
"Simply create a tree fragment using the name of the test-case in parse errors."
if
pxds
is
None
:
pxds
=
{}
if
pipeline
is
None
:
pipeline
=
[]
name
=
self
.
id
()
if
name
.
startswith
(
"__main__."
):
name
=
name
[
len
(
"__main__."
):]
if
name
.
startswith
(
"__main__."
):
name
=
name
[
len
(
"__main__."
):]
name
=
name
.
replace
(
"."
,
"_"
)
return
TreeFragment
(
code
,
name
,
pxds
,
pipeline
=
pipeline
)
...
...
@@ -139,7 +144,9 @@ class TransformTest(CythonTest):
Plans: One could have a pxd dictionary parameter to run_pipeline.
"""
def
run_pipeline
(
self
,
pipeline
,
pyx
,
pxds
=
{}):
def
run_pipeline
(
self
,
pipeline
,
pyx
,
pxds
=
None
):
if
pxds
is
None
:
pxds
=
{}
tree
=
self
.
fragment
(
pyx
,
pxds
).
root
# Run pipeline
for
T
in
pipeline
:
...
...
pyximport/pyxbuild.py
View file @
d6aa0e99
...
...
@@ -19,9 +19,9 @@ DEBUG = 0
_reloads
=
{}
def
pyx_to_dll
(
filename
,
ext
=
None
,
force_rebuild
=
0
,
build_in_temp
=
False
,
pyxbuild_dir
=
None
,
setup_args
=
{}
,
reload_support
=
False
,
inplace
=
False
):
def
pyx_to_dll
(
filename
,
ext
=
None
,
force_rebuild
=
0
,
build_in_temp
=
False
,
pyxbuild_dir
=
None
,
setup_args
=
None
,
reload_support
=
False
,
inplace
=
False
):
"""Compile a PYX file to a DLL and return the name of the generated .so
or .dll ."""
assert
os
.
path
.
exists
(
filename
),
"Could not find %s"
%
os
.
path
.
abspath
(
filename
)
...
...
@@ -35,6 +35,8 @@ def pyx_to_dll(filename, ext = None, force_rebuild = 0,
filename
=
filename
[:
-
len
(
extension
)]
+
'.c'
ext
=
Extension
(
name
=
modname
,
sources
=
[
filename
])
if
setup_args
is
None
:
setup_args
=
{}
if
not
pyxbuild_dir
:
pyxbuild_dir
=
os
.
path
.
join
(
path
,
"_pyxbld"
)
...
...
@@ -151,6 +153,7 @@ def pyx_to_dll(filename, ext = None, force_rebuild = 0,
sys
.
stderr
.
write
(
error
+
"
\
n
"
)
raise
if
__name__
==
"__main__"
:
pyx_to_dll
(
"dummy.pyx"
)
from
.
import
test
...
...
pyximport/pyximport.py
View file @
d6aa0e99
...
...
@@ -471,7 +471,7 @@ def _have_importers():
def
install
(
pyximport
=
True
,
pyimport
=
False
,
build_dir
=
None
,
build_in_temp
=
True
,
setup_args
=
{}
,
reload_support
=
False
,
setup_args
=
None
,
reload_support
=
False
,
load_py_module_on_import_failure
=
False
,
inplace
=
False
,
language_level
=
None
):
"""Main entry point. Call this to install the .pyx import hook in
...
...
@@ -518,6 +518,8 @@ def install(pyximport=True, pyimport=False, build_dir=None, build_in_temp=True,
The default is to use the language level of the current Python
runtime for .py files and Py2 for .pyx files.
"""
if
setup_args
is
None
:
setup_args
=
{}
if
not
build_dir
:
build_dir
=
os
.
path
.
join
(
os
.
path
.
expanduser
(
'~'
),
'.pyxbld'
)
...
...
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