numba:高性能Python编译器

numba是一个提供以注解形式高性能编译的python库。

最基础的就是  @jit  ,对for循环有明显的加速

from numba import jit

@jit
def f(x, y):
    # A somewhat trivial example
    return x + y

另外用到了  @jit(nopython=True)

在实际使用的过程中,注解对应的函数内部调用了其他函数或者对象会导致注解无法识别引起异常。


  • @njit - this is an alias for @jit(nopython=True) as it is so commonly used!
  • @vectorize - produces NumPy ufunc s (with all the ufunc methods supported). 
  • @guvectorize - produces NumPy generalized ufunc s. 
  • @stencil - declare a function as a kernel for a stencil like operation. 
  • @jitclass - for jit aware classes. 
  • @cfunc - declare a function for use as a native call back (to be called from C/C++ etc). 
  • @overload - register your own implementation of a function for use in nopython mode, e.g. @overload(scipy.special.j0)

官网地址:http://numba.pydata.org/

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值