Commit 3070370a authored by scoder's avatar scoder Committed by GitHub

Merge pull request #2595 from alubbock/inline_directives

cython_inline compiler directives support
parents ab544dfa be211dd2
...@@ -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()
......
...@@ -60,6 +60,14 @@ class TestInline(CythonTest): ...@@ -60,6 +60,14 @@ class TestInline(CythonTest):
""", a=3, **self.test_kwds) """, a=3, **self.test_kwds)
self.assertEquals(type(b), float) self.assertEquals(type(b), float)
def test_compiler_directives(self):
self.assertEqual(
inline('return sum(x)',
x=[1, 2, 3],
cython_compiler_directives={'boundscheck': False}),
6
)
if has_numpy: if has_numpy:
def test_numpy(self): def test_numpy(self):
......
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