Questions tagged [numba]

Numba is an open source NumPy-aware optimizing compiler for Python.

Numba is an Open Source NumPy-aware optimizing compiler for Python sponsored by Continuum Analytics, Inc. It uses the remarkable LLVM compiler infrastructure to compile Python syntax to machine code.

It is aware of NumPy arrays as typed memory regions and so can speed-up code using NumPy arrays. Other, less well-typed code will be translated to Python C-API calls effectively removing the "interpreter" but not removing the dynamic indirection.

Numba is also not a tracing jit. It compiles your code before it gets run either using run-time type information or type information you provide in the decorator.

Numba is a mechanism for producing machine code from Python syntax and typed data structures such as those that exist in NumPy.

Source: README.rst of the Numba project (GitHub).

More informations about the package can be found on the Numba homepage and documentation.

1558 questions
30
votes
3 answers

Improve Pandas Merge performance

I specifically dont have performace issue with Pands Merge, as other posts suggest, but I've a class in which there are lot of methods, which does a lot of merge on datasets. The class has around 10 group by and around 15 merge. While groupby is…
Debasish Kanhar
  • 813
  • 1
  • 13
  • 23
30
votes
6 answers

Matrix inversion without Numpy

I want to invert a matrix without using numpy.linalg.inv. The reason is that I am using Numba to speed up the code, but numpy.linalg.inv is not supported, so I am wondering if I can invert a matrix with 'classic' Python code. With numpy.linalg.inv…
30
votes
2 answers

Multiple output and numba signatures

Maybe it is trivial, but I was wondering how to write signatures in the jit decorator when there are several outputs. For instance : import numba as nb @nb.jit(['???(int32, int32, float(:,:), float(:,:))'], nopython=True) def foo(nx, ny, a, b): …
Ipse Lium
  • 672
  • 1
  • 5
  • 15
29
votes
2 answers

How do I use numba on a member function of a class?

I'm using the stable version of Numba 0.30.1. I can do this: import numba as nb @nb.jit("void(f8[:])",nopython=True) def complicated(x): for a in x: b = a**2.+a**3. as a…
dbrane
  • 597
  • 1
  • 5
  • 14
29
votes
2 answers

Python numpy: cannot convert datetime64[ns] to datetime64[D] (to use with Numba)

I want to pass a datetime array to a Numba function (which cannot be vectorised and would otherwise be very slow). I understand Numba supports numpy.datetime64. However, it seems it supports datetime64[D] (day precision) but not datetime64[ns]…
Pythonista anonymous
  • 5,770
  • 14
  • 47
  • 87
29
votes
4 answers

Why is numba faster than numpy here?

I can't figure out why numba is beating numpy here (over 3x). Did I make some fundamental error in how I am benchmarking here? Seems like the perfect situation for numpy, no? Note that as a check, I also ran a variation combining numba and numpy…
JohnE
  • 23,768
  • 8
  • 66
  • 93
26
votes
10 answers

Getting python Numba working on Ubuntu 14.10 or Fedora 21 with python 2.7

Recently, I have had a frustrating time to get python Numba working on Ubuntu or Fedora Linux. The main problem has been with the compilation of llvmlite. What do I need to install for these to compile properly?
mettw
  • 439
  • 5
  • 6
23
votes
4 answers

Finding nearest neighbours of a triangular tesellation

I have a triangular tessellation like the one shown in the figure. Given N number of triangles in the tessellation, I have a N X 3 X 3 array which stores (x, y, z) coordinates of all three vertices of each triangle. My goal is to find for each…
konstant
  • 675
  • 5
  • 18
23
votes
8 answers

Cuda: library nvvm not found

I am trying to run the code below but an error is reported: NvvmSupportError: libNVVM cannot be found. Do conda install cudatoolkit: library nvvm not found My development environment is: Ubuntu 17.04, Spyder/Python3.5 and I have installed via conda…
Helton Maia
  • 231
  • 1
  • 3
  • 5
23
votes
5 answers

Python: rewrite a looping numpy math function to run on GPU

Can someone help me rewrite this one function (the doTheMath function) to do the calculations on the GPU? I used a few good days now trying to get my head around it but to no result. I wonder maybe somebody can help me rewrite this function in…
RaduS
  • 1,938
  • 7
  • 37
  • 61
22
votes
4 answers

Comparing Python, Numpy, Numba and C++ for matrix multiplication

In a program I am working on, I need to multiply two matrices repeatedly. Because of the size of one of the matrices, this operation takes some time and I wanted to see which method would be the most efficient. The matrices have dimensions (m x…
JD80121
  • 477
  • 3
  • 12
21
votes
1 answer

Filtering a NumPy Array: what is the best approach?

Suppose I have a NumPy array arr that I want to element-wise filter, e.g. I want to get only values below a certain threshold value k. There are a couple of methods, e.g.: Using generators: np.fromiter((x for x in arr if x < k),…
norok2
  • 18,523
  • 3
  • 47
  • 78
21
votes
2 answers

How to parallelize this Python for loop when using Numba

I'm using the Anaconda distribution of Python, together with Numba, and I've written the following Python function that multiplies a sparse matrix A (stored in a CSR format) by a dense vector x: @jit def csrMult( x, Adata, Aindices, Aindptr, Ashape…
littleO
  • 812
  • 1
  • 8
  • 24
20
votes
1 answer

Performance of various numpy fancy indexing methods, also with numba

Since for my program fast indexing of Numpy arrays is quite necessary and fancy indexing doesn't have a good reputation considering performance, I decided to make a few tests. Especially since Numba is developing quite fast, I tried which methods…
JE_Muc
  • 4,601
  • 2
  • 18
  • 32
18
votes
2 answers

How to make numba @jit use all cpu cores (parallelize numba @jit)

I am using numbas @jit decorator for adding two numpy arrays in python. The performance is so high if I use @jit compared with python. However it is not utilizing all CPU cores even if I pass in @numba.jit(nopython = True, parallel = True, nogil =…
user8353052
1
2 3
99 100