instant.inlining

Package instant :: Module inlining |
[hide private]
[frames] | no frames]

# Module inlining

source code

This module contains the inline* functions, which allows easy inlining of C/C++ functions.

Functions | [hide private]
get_func_name(c_code) | source code
inline(c_code, **kwargs) This is a short wrapper around the build_module function in instant. | source code
inline_module(c_code, **kwargs) This is a short wrapper around the build_module function in instant. | source code
inline_with_numpy(c_code, **kwargs) This is a short wrapper around the build_module function in instant. | source code
inline_module_with_numpy(c_code, **kwargs) This is a short wrapper around the build_module function in instant. | source code

Variables | [hide private]
| __package__ = ``'``instant``'``

Function Details | [hide private]

### inline(c_code, **kwargs) | source code
This is a short wrapper around the build_module function in instant. It creates a module given that the input is a valid C function. It is only possible to inline one C function each time. Usage:
    >>> from instant import inline
    >>> add_func = inline("double add(double a, double b){ return a+b; }")
    >>> print "The sum of 3 and 4.5 is ", add_func(3, 4.5)

### inline_module(c_code, **kwargs) | source code
This is a short wrapper around the build_module function in instant. It creates a module given that the input is a valid C function. It is only possible to inline one C function each time. Usage:
    >>> from instant import inline
    >>> add_func = inline("double add(double a, double b){ return a+b; }")
    >>> print "The sum of 3 and 4.5 is ", add_func(3, 4.5)

### inline_with_numpy(c_code, **kwargs) | source code
This is a short wrapper around the build_module function in instant. It creates a module given that the input is a valid C function. It is only possible to inline one C function each time. The difference between this function and the inline function is that C-arrays can be used. The following example illustrates that. Usage:
    >>> import numpy
    >>> import time
    >>> from instant import inline_with_numpy
    >>> c_code = """
        double sum (int n1, double* array1){
            double tmp = 0.0;
            for (int i=0; i<n1; i++) {
                tmp += array1[i];
            }
            return tmp;
        }
        """
    >>> sum_func = inline_with_numpy(c_code,  arrays = [['n1', 'array1']])
    >>> a = numpy.arange(10000000); a = numpy.sin(a)
    >>> sum_func(a)

### inline_module_with_numpy(c_code, **kwargs) | source code
This is a short wrapper around the build_module function in instant. It creates a module given that the input is a valid C function. It is only possible to inline one C function each time. The difference between this function and the inline function is that C-arrays can be used. The following example illustrates that. Usage:
    >>> import numpy
    >>> import time
    >>> from instant import inline_with_numpy
    >>> c_code = """
        double sum (int n1, double* array1){
            double tmp = 0.0;
            for (int i=0; i<n1; i++) {
                tmp += array1[i];
            }
            return tmp;
        }
        """
    >>> sum_func = inline_with_numpy(c_code,  arrays = [['n1', 'array1']])
    >>> a = numpy.arange(10000000); a = numpy.sin(a)
    >>> sum_func(a)