Advanced·12 min·advanced · numpy · data
NumPy: arrays at speed
NumPy: arrays at speed
NumPy gives you arrays — typed, contiguous, blazing fast.
Why it matters
- Operations are vectorized —
xs * xsruns in C, not Python. - One million points: pure Python takes seconds. NumPy: milliseconds.
Pyodide magic
The first time you run import numpy, the worker auto-downloads NumPy from the CDN.
After that, it's cached in your browser.
Try it
- Bump the sample size to 5 million. Notice the run still finishes quickly.
- Add a histogram:
np.histogram(xs, bins=20)and print the counts.