A first glimpse of NumPy

Import (more on this later...):
from numpy import *
x = linspace(0, 1, 1001)   # 1001 values between 0 and 1
x = sin(x)                 # computes sin(x[0]), sin(x[1]) etc.
x=sin(x) is 13 times faster than an explicit loop:
for i in range(len(x)):
    x[i] = sin(x[i])
because sin(x) invokes an efficient loop in C

previousnexttable of contents