enhancements inline

robertwb edited this page Feb 14, 2011 · 6 revisions

CEP 109 - Runtime compilation

  • Status: Released as part of 0.14 (December 2010)

Concept

One very useful feature for fast prototyping of code is weave.inline, which allows one to compile inline chunks of code on the fly. Specialized code is compiled based on the types of inline variables (pulled from the surrounding scope), and cached for later use. A simple usecase would be

import cython

cython.inline("print x*x", x=3)

To get a result back, the return statement is used, e.g.

a = 100.
result = cython.inline("return a + 1")

Assuming we can get the source, we can also do

@cython.compile
def f(x, y, z):
    ...

Numpy array types are optimized as well.

Clone this wiki locally
You can’t perform that action at this time.
You signed in with another tab or window. Reload to refresh your session. You signed out in another tab or window. Reload to refresh your session.
Press h to open a hovercard with more details.