Should I use scipy.pi, numpy.pi, or math.pi?

Douglas B. Staple picture Douglas B. Staple · Sep 28, 2012 · Viewed 164.1k times · Source

In a project using SciPy and NumPy, should I use scipy.pi, numpy.pi, or math.pi?

Answer

BrenBarn picture BrenBarn · Sep 28, 2012
>>> import math
>>> import numpy as np
>>> import scipy
>>> math.pi == np.pi == scipy.pi
True

So it doesn't matter, they are all the same value.

The only reason all three modules provide a pi value is so if you are using just one of the three modules, you can conveniently have access to pi without having to import another module. They're not providing different values for pi.