Commit 8aa581be authored by Robert Bradshaw's avatar Robert Bradshaw

A 10x cython.inline speed improvement.

parent 0db6c709
...@@ -102,6 +102,10 @@ def _get_build_extension(): ...@@ -102,6 +102,10 @@ def _get_build_extension():
build_extension.finalize_options() build_extension.finalize_options()
return build_extension return build_extension
@cached_function
def _create_context(cython_include_dirs):
return Context(list(cython_include_dirs), default_options)
def cython_inline(code, def cython_inline(code,
get_type=unsafe_type, get_type=unsafe_type,
lib_dir=os.path.join(get_cython_cache_dir(), 'inline'), lib_dir=os.path.join(get_cython_cache_dir(), 'inline'),
...@@ -117,7 +121,7 @@ def cython_inline(code, ...@@ -117,7 +121,7 @@ def cython_inline(code,
orig_code = code orig_code = code
code, literals = strip_string_literals(code) code, literals = strip_string_literals(code)
code = strip_common_indent(code) code = strip_common_indent(code)
ctx = Context(cython_include_dirs, default_options) ctx = _create_context(tuple(cython_include_dirs))
if locals is None: if locals is None:
locals = inspect.currentframe().f_back.f_back.f_locals locals = inspect.currentframe().f_back.f_back.f_locals
if globals is None: if globals is None:
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment