Search icon
Arrow left icon
All Products
Best Sellers
New Releases
Books
Videos
Audiobooks
Learning Hub
Newsletters
Free Learning
Arrow right icon
Learning Cython Programming (Second Edition) - Second Edition

You're reading from  Learning Cython Programming (Second Edition) - Second Edition

Product type Book
Published in Feb 2016
Publisher Packt
ISBN-13 9781783551675
Pages 110 pages
Edition 2nd Edition
Languages
Author (1):
Philip Herron Philip Herron
Profile icon Philip Herron

Numba versus Cython


Numba is another way to get your Python code to become almost native to your host system by outputting the code to be run on LLVM seamlessly. Numba makes use of decorators such as the following:

@autojit
def myFunction (): ...

Numba also integrates with NumPy. On the whole, it sounds great. Unlike Cython, you only apply decorators to pure Python code, and it does everything for you, but you may find that the optimizations will be fewer and not as powerful.

Numba does not integrate with C/C++ to the extent that Cython does. If you want it to integrate, you need to use Foreign Function Interfaces (FFI) to wrap calls. You also need to define structs and work with C types in Python code in a very abstract sense to a point where you don't really have much control as compared with Cython.

Numba is mostly comprised of decorators, such as @locals, from Cython. But in the end, all this creates is just-in-time-compiled functions with a proper native function signature. Since you can...

lock icon The rest of the chapter is locked
Register for a free Packt account to unlock a world of extra content!
A free Packt account unlocks extra newsletters, articles, discounted offers, and much more. Start advancing your knowledge today.
Unlock this book and the full library FREE for 7 days
Get unlimited access to 7000+ expert-authored eBooks and videos courses covering every tech area you can think of
Renews at €14.99/month. Cancel anytime}