SciPy or NumPy

>>> np.fft.fft is sp.fftpack.fft

False # 両者の関数の実体が違う

>>> np.polyfit is sp.polyfit

True # 両者の関数の実体が同じ

もしSciPyとNumPyで同じ機能を持つ関数が,別に提供されている場合は,たいていSciPyの方が計算速度で有利である.そのため,SciPyの関数を使う方がよい.たとえば,scipyfftpack.fftはnumpy.fft.fftよりも高速だ.

なお,SciPyをインストールすると,NumPyの関数がSciPyの関数としても使えるようになる場合がある.この場合は,関数の実体は同じなので,SciPyとしての関数を使ったからといって高速になることはない.実体が同じか違うかは,次の例のようにis文で調べることができる.

If SciPy and NumPy provide functions with the same function separately, SciPy is usually more advantageous in computation speed. Therefore, it is better to use the SciPy function. For example, scipyfftpack.fft is faster than numpy.fft.fft.

Note that if you install SciPy, the NumPy function may be available as a function of SciPy in some cases. In this case, the entities of the functions are the same, so using the function as SciPy will not be faster. Whether the entities are the same or different can be examined with the is statement as in the following example.

>>> np.fft.fft is sp.fftpack.fft

False # entities are different

>>> np.polyfit is sp.polyfit

True # entities are the same