Hacker News new | ask | show | jobs
by nknealk 2072 days ago
Numba is actually a pretty interesting project. It allows you to JIT compile a single function with a decorator. Static typing required, and it plays nice with numpy. They’ve also got some interesting stuff going on that lets you interface with nvidia GPUs as well.

Highly recommend it for anyone doing scientific computing

3 comments

I agree, Numba is awesome for lots of reasons. The biggest advantage for everyone, the Numba team as well as its users, is that it is opt-in and done with intent. The programmer is saying, "I am willing to constrain my code to get perf". And that you can do that inside an existing runtime is pretty damn cool.

I think for Python to get decent speedups the semantics for the code being optimized needs to be highly constrained.

Optimizing full in the wild Python code is a huge huge task. Optimizing for operations over constant type arrays is much much easier.

Yes this doesn't speed up the call or the allocation rate, but start with some easy stuff or nothing will improve.

Numba is indeed a great library for speeding up Python and also doing other useful things when interacting when external libraries.

For example the "jit compile a single function" feature is gold when you need to pass a function callback pointer into a C library. This is how pygraphblas compiles Python functions into semiring operators that are then passed to the library which has no idea that the pointer is to jit compiled python function:

https://github.com/michelp/pygraphblas/blob/master/tests/tes...

Forgive my ignorance, I'm not super knowledgable on the subject but does this mean you just add decorators to existing functions with typing and it enhances the speed?
Yes, but types not required.

  from numba import jit

  @jit
  def jitted_fn():
https://numba.readthedocs.io/en/stable/user/jit.html
So, does that mean Numba performs some sort of type inference on Python?