You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
In [4]: %timeit apply_integrate_f_wrap(df['a'].values, df['b'].values, df['N'].values)
288
+
1000 loops, best of 3: 987 us per loop
284
289
285
290
Even faster, with the caveat that a bug in our cython code (an off-by-one error,
286
291
for example) might cause a segfault because memory access isn't checked.
287
292
288
293
289
-
Further topics
290
-
~~~~~~~~~~~~~~
294
+
.. _enhancingperf.numba:
295
+
296
+
Using numba
297
+
-----------
298
+
299
+
A recent alternative to statically compiling cython code, is to use a *dynamic jit-compiler*, ``numba``.
300
+
301
+
Numba gives you the power to speed up your applications with high performance functions written directly in Python. With a few annotations, array-oriented and math-heavy Python code can be just-in-time compiled to native machine instructions, similar in performance to C, C++ and Fortran, without having to switch languages or Python interpreters.
302
+
303
+
Numba works by generating optimized machine code using the LLVM compiler infrastructure at import time, runtime, or statically (using the included pycc tool). Numba supports compilation of Python to run on either CPU or GPU hardware, and is designed to integrate with the Python scientific software stack.
304
+
305
+
.. note::
306
+
307
+
You will need to install ``numba``. This is easy with ``conda``, by using: ``conda install numba``, see :ref:`installing using miniconda<install.miniconda>`.
308
+
309
+
We simply take the plain python code from above and annotate with the ``@jit`` decorator.
0 commit comments