{ inercia }

  • Archive
  • RSS
  • Ask me anything

Numba: a Python-to-LLVM compiler

From the home page:

Numba is an Open Source NumPy-aware optimizing compiler for Python […]. It uses the remarkable LLVM compiler infrastructure to compile Python byte-code to machine code especially for use in the NumPy run-time and SciPy modules.

I’ve found this article where they compare Numba with Cython, and it seems it gives really good performance by just adding some annotations. This is the code they use:

import numpy as np
from numba import double
from numba.decorators import jit

@jit(arg_types=[double[:,:], double[:,:]])
def pairwise_numba(X, D):
    M = X.shape[0]
    N = X.shape[1]
    for i in range(M):
        for j in range(M):
            d = 0.0
            for k in range(N):
                tmp = X[i, k] - X[j, k]
                d += tmp * tmp
            D[i, j] = np.sqrt(d)
    • #numba
    • #cython
    • #llvm
    • #python
  • 7 months ago
  • 5
  • Permalink
  • Share

5 Notes/ Hide

  1. macarenomarco likes this
  2. daisyrosedigital likes this
  3. yani12 likes this
  4. repejota reblogged this from inercia
  5. repejota likes this
  6. chelsie101 likes this
  7. inercia posted this
← Previous • Next →

About

Avatar My name is Alvaro and I´m currently working in Telefonica R&D in Barcelona (Spain). I previously lived in Madrid, Edinburgh, Glasgow, Michigan (USA) and A Coruña (Spain).

Pages

  • My background
  • My linkedin
  • My facebook
  • My github

Find me elsewhere...

  • @inercia_tech on Twitter
  • Facebook Profile
  • inercia on Flickr
  • Call me on Skype
  • Linkedin Profile
  • inercia on github
  • RSS
  • Random
  • Archive
  • Ask me anything
  • Mobile

Effector Theme by Carlo Franco.

Powered by Tumblr