Пример #1
0
    def _jit(func):
        global __tr_map__

        llvm = kws.pop('llvm', True)
        if func in __tr_map__:
            logger.warning("Warning: Previously compiled version of %r may be "
                           "garbage collected!" % (func,))

        use_ast = False
        if backend == 'ast':
            use_ast = True
            if argtypes and restype:
                for arg_type in list(argtypes) + [restype]:
                    if not isinstance(arg_type, minitypes.Type):
                        use_ast = False
                        debugout("String type specified, using bytecode translator...")
                        break

        if use_ast:
            return jit2(argtypes=argtypes)(func)
        else:
            if argtypes is None:
                argtyps = [double]
            else:
                argtyps = argtypes
            t = bytecode_translate.Translate(func, restype=restype or double,
                                             argtypes=argtyps, **kws)
            t.translate()
            # print t.lfunc
            __tr_map__[func] = t
            ctypes_func = t.get_ctypes_func(llvm)
            return NumbaFunction(func, ctypes_func=ctypes_func, lfunc=t.lfunc)
Пример #2
0
def demo_function (min_x, max_x, min_y, out_arr):
    width = out_arr.shape[0]
    height = out_arr.shape[1]
    delta = (max_x - min_x) / width
    for x in range(width):
        x_val = min_x + x * delta
        for y in range(height):
            y_val = min_y + y * delta
            debugout("demo_function(): x = ", x, ", y =", y, ", x_val = ",
                     x_val, ", y_val = ", y_val)
            out_arr[x, y, 0] = x_val
            out_arr[x, y, 1] = y_val
Пример #3
0
def demo_function (min_x, max_x, min_y, out_arr):
    width = out_arr.shape[0]
    height = out_arr.shape[1]
    delta = (max_x - min_x) / width
    for x in range(width):
        x_val = min_x + x * delta
        for y in range(height):
            y_val = min_y + y * delta
            debugout("demo_function(): x = ", x, ", y =", y, ", x_val = ",
                     x_val, ", y_val = ", y_val)
            out_arr[x, y, 0] = x_val
            out_arr[x, y, 1] = y_val
Пример #4
0
    def _jit(func):
        global __tr_map__

        llvm = kws.pop('llvm', True)
        if func in __tr_map__:
            logger.warning("Warning: Previously compiled version of %r may be "
                           "garbage collected!" % (func, ))

        use_ast = False
        if backend == 'ast':
            use_ast = True
            if argtypes and restype:
                for arg_type in list(argtypes) + [restype]:
                    if not isinstance(arg_type, minitypes.Type):
                        use_ast = False
                        debugout(
                            "String type specified, using bytecode translator..."
                        )
                        break

        if use_ast:
            return jit2(argtypes=argtypes)(func)
        else:
            if argtypes is None:
                argtyps = [double]
            else:
                argtyps = argtypes
            t = bytecode_translate.Translate(func,
                                             restype=restype or double,
                                             argtypes=argtyps,
                                             **kws)
            t.translate()
            # print t.lfunc
            __tr_map__[func] = t
            ctypes_func = t.get_ctypes_func(llvm)
            return NumbaFunction(func, ctypes_func=ctypes_func, lfunc=t.lfunc)
Пример #5
0
    def _jit(func):
        global __tr_map__
        llvm = kws.pop('llvm', True)
        if func in __tr_map__:
            logger.warning("Warning: Previously compiled version of %r may be "
                           "garbage collected!" % (func,))

        use_ast = False
        if backend == 'ast':
            use_ast = True
            for arg_type in list(arg_types) + [ret_type]:
                if not isinstance(arg_type, minitypes.Type):
                    use_ast = False
                    debugout("String type specified, using bytecode translator...")
                    break

        if use_ast:
            return jit_ast(arg_types=arg_types)(func)
        else:
            t = bytecode_translate.Translate(func, ret_type=ret_type,
                                             arg_types=arg_types, **kws)
            t.translate()
            __tr_map__[func] = t
            return t.get_ctypes_func(llvm)