首页 > 解决方案 > Numba 嵌套函数不会执行(0.47 版)

问题描述

我很困惑为什么这不起作用,文档说:

2.6.1.2.3。内部函数和闭包:Numba 现在支持内部函数,只要它们是非递归的并且仅在本地调用,但不作为参数传递或作为结果返回。还支持在内部函数中使用闭包变量(在外部范围中定义的变量)。

import numba

@numba.jit(nopython=True, debug=False, parallel=False, cache=True)
def outer() -> int:

    @numba.jit(nopython=True, debug=False, parallel=False, cache=True)
    def inner() -> int:
        return 1

    return inner()

outer()

和错误:

Failed in nopython mode pipeline (step: analyzing bytecode)
op_MAKE_FUNCTION with annotations is not implemented

我在这里做傻事吗?

(操作系统:Ubuntu 19.10)

标签: pythonnumba

解决方案


Soln:不要使用类型声明并删除内部 j​​it 装饰器


推荐阅读