(code, argcount=None, fname='f', fprototype=None)
return fprototype(symbol.value)
C code with function -> compiled function

    Supports all standard C math functions, pi and e.
    Function is assumed to get and return 'double' only.
    Uses libtcc.
C code with function -> compiled function
C code with function - > compiled function
def _compile(code, argcount=None, fname='f', fprototype=None):
    """
    C code with function -> compiled function

    Supports all standard C math functions, pi and e.
    Function is assumed to get and return 'double' only.
    Uses libtcc.
    """
    # returned type and all arguments are double
    if fprototype:
        fprototype = ctypes.CFUNCTYPE(*fprototype)
    else:
        if not argcount:
            raise ValueError("need argcount if no prototype is specified")
        fprototype = ctypes.CFUNCTYPE(*[ctypes.c_double]*(argcount + 1))
    # see libtcc.h for API documentation
    tccstate = libtcc.tcc_new()
    __run(libtcc.tcc_set_output_type(tccstate, 0))  # output to memory
    ##print libtcc.tcc_add_library_path(tccstate, mathh) # could be dropped
    __run(libtcc.tcc_add_library(tccstate, 'm'))  # use math.h FIXME: Windows
    # compile string
    __run(libtcc.tcc_compile_string(tccstate, code))
    __run(libtcc.tcc_relocate(tccstate))  # fails if link error
    # create C variable to get result
    symbol = ctypes.c_long()
    __run(libtcc.tcc_get_symbol(tccstate, ctypes.byref(symbol), fname))
    # return reference to C function
    return fprototype(symbol.value)
def _compile ( code , argcount = None , fname = 'f' , fprototype = None ) : # returned type and all arguments are double if fprototype : fprototype = ctypes . CFUNCTYPE ( * fprototype ) else : if not argcount : raise ValueError ( "need argcount if no prototype is specified" ) fprototype = ctypes . CFUNCTYPE ( * [ ctypes . c_double ] * ( argcount + 1 ) ) # see libtcc.h for API documentation tccstate = libtcc . tcc_new ( ) __run ( libtcc . tcc_set_output_type ( tccstate , 0 ) ) # output to memory ##print libtcc.tcc_add_library_path(tccstate, mathh) # could be dropped __run ( libtcc . tcc_add_library ( tccstate , 'm' ) ) # use math.h FIXME: Windows # compile string __run ( libtcc . tcc_compile_string ( tccstate , code ) ) __run ( libtcc . tcc_relocate ( tccstate ) ) # fails if link error # create C variable to get result symbol = ctypes . c_long ( ) __run ( libtcc . tcc_get_symbol ( tccstate , ctypes . byref ( symbol ) , fname ) ) # return reference to C function return fprototype ( symbol . value )