finds.dev← search

// the find

rougier/from-python-to-numpy

★ 2,154 · Python · NOASSERTION · updated May 2025

An open-access book on numpy vectorization techniques, Nicolas P. Rougier, 2017

A free 2017 online book by a computational neuroscientist on thinking in numpy terms instead of writing Python loops, built around worked case studies (boid flocking, Game of Life, Mandelbrot, a smoke solver) rather than API reference. Aimed at developers who already know numpy's syntax but still default to for-loops and want a framework for when and how to vectorize.

The code/problem/custom vectorization taxonomy is a real contribution — most numpy writeups show the trick, this one explains which category of trick applies and why, which is the part people actually get stuck on. Every case study ships a working python-loop version next to the numpy version in code/, so you can diff them directly instead of taking the author's word for the speedup. It's genuinely free with no email gate, just RST source plus a prebuilt book.html you can read offline.

Content hasn't moved since 2017 — no mention of numpy's newer array API, no discussion of numba/cupy as alternatives once 'custom vectorization' stops paying off, and some strides/np.vectorize advice is dated relative to current numpy internals. CC BY-NC-SA blocks commercial reuse, so a team can't fold chapters into internal onboarding docs without asking. There are no notebooks, only RST and static scripts, so there's no inline way to run an example without cloning the repo and executing it yourself. It's a straight read with no exercises, so it teaches by example rather than by practice.

View on GitHub → Homepage ↗

// want more like this?

We dig through GitHub every week and send a few repos picked for what you actually care about — each with an honest take like this one.

Get finds in your inbox → Search again →