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
9de33b2a
Commit
9de33b2a
authored
Nov 05, 2010
by
Robert Bradshaw
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
More module caching.
parent
858709b6
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
13 additions
and
9 deletions
+13
-9
Cython/Build/Inline.py
Cython/Build/Inline.py
+13
-9
No files found.
Cython/Build/Inline.py
View file @
9de33b2a
...
...
@@ -12,6 +12,7 @@ except ImportError:
from
distutils.core
import
Distribution
,
Extension
from
distutils.command.build_ext
import
build_ext
import
Cython
from
Cython.Compiler.Main
import
Context
,
CompilationOptions
,
default_options
from
Cython.Compiler.ParseTreeTransforms
import
CythonTransform
,
SkipDeclarations
,
AnalyseDeclarationsTransform
...
...
@@ -106,8 +107,14 @@ def cython_inline(code,
arg_names
.
sort
()
arg_sigs
=
tuple
([(
get_type
(
kwds
[
arg
],
ctx
),
arg
)
for
arg
in
arg_names
])
key
=
code
,
arg_sigs
module
=
_code_cache
.
get
(
key
)
if
not
module
:
module_name
=
_code_cache
.
get
(
key
)
if
module_name
is
None
:
module_name
=
"_cython_inline_"
+
hashlib
.
md5
(
code
+
str
(
arg_sigs
)
+
Cython
.
__version__
).
hexdigest
()
try
:
if
lib_dir
not
in
sys
.
path
:
sys
.
path
.
append
(
lib_dir
)
__import__
(
module_name
)
except
ImportError
:
cimports
=
[]
qualified
=
re
.
compile
(
r'([.\
w]+)[.]
')
for type, _ in arg_sigs:
...
...
@@ -124,24 +131,21 @@ def __invoke(%(params)s):
""" % {'
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)
module = "_" + hashlib.md5(code + str(arg_sigs)).hexdigest()
pyx_file = os.path.join(tempfile.mkdtemp(), module + '
.
pyx
')
pyx_file = os.path.join(tempfile.mkdtemp(), module_name + '
.
pyx
')
open(pyx_file, '
w
').write(module_code)
extension = Extension(
name = module,
name = module
_name
,
sources = [pyx_file],
pyrex_include_dirs = include_dirs)
build_extension = build_ext(Distribution())
build_extension.finalize_options()
build_extension.extensions = cythonize([extension])
build_extension.build_temp = os.path.dirname(pyx_file)
if lib_dir not in sys.path:
sys.path.append(lib_dir)
build_extension.build_lib = lib_dir
build_extension.run()
_code_cache[key] = module
_code_cache[key] = module
_name
arg_list = [kwds[arg] for arg in arg_names]
return __import__(module).__invoke(*arg_list)
return __import__(module
_name
).__invoke(*arg_list)
non_space = re.compile('
[
^
]
')
def strip_common_indent(code):
...
...
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