def process_untyped_methods(self, env, extclass, ext_type): """ Process autojit methods (undecorated methods). Use the fast NumbaSpecializingWrapper cache when for when we're being called from python. When we need to add a new specialization, `autojit_method_compiler` is invoked to compile the method. extclass: the extension type ext_type.py_class: the unspecialized class that was decorated """ from numba.wrapping import compiler for method_name, method in ext_type.vtab_type.untyped_methods.iteritems(): env.specializations.register(method.py_func) cache = env.specializations.get_autojit_cache(method.py_func) compiler_impl = compiler.MethodCompiler(env, extclass, method) wrapper = numbawrapper.NumbaSpecializingWrapper( method.py_func, compiler_impl, cache) setattr(extclass, method_name, wrapper)
def autojit_class_wrapper(py_class, compiler_impl, cache): """ Invoked when a class is decorated with @autojit. :param py_class: decorated python class :param compiler_impl: compiler.ClassCompiler :param cache: FunctionCache :return: py_class that returns specialized object instances """ from numba import numbawrapper if utils.is_numba_class(py_class): raise error.NumbaError("Subclassing not yet supported " "for autojit classes") # runtime_args -> specialized extension type instance class_specializer = numbawrapper.NumbaSpecializingWrapper( py_class, compiler_impl, cache) py_class = autojitmeta.create_unspecialized_cls(py_class, class_specializer) py_class.__is_numba_autojit = True # Update the class from which we derive specializations (which will be # passed to create_extension() below) compiler_impl.py_func = py_class # Back up class dict, since we're going to modify it py_class.__numba_class_dict = dict(vars(py_class)) # Make delegation methods for unbound methods make_delegations(py_class) # Setup up partial compilation environment # partial_env = create_partial_extension_environment( # compiler_impl.env, py_class, compiler_impl.flags) # compiler_impl.partial_ext_env = partial_env return py_class