[SciPy-User] [SciPy-user] Convention and preferred practice when importing scipy

Robert Kern robert.kern@gmail....
Mon Oct 11 13:44:33 CDT 2010

On Mon, Oct 11, 2010 at 13:35, omnyx <ognjen.i@gmail.com> wrote:
> Upon reading
> http://www.scipy.org/Getting_Started#head-eefd39e27392d16c48eb5350bc05b4b7045ffcd9
> is it then true that using
> import scipy as sc
> is as fast as
> import numpy as np ?
> (sc,np just shortcut names)
> I only need a couple of scipy built-in functions but too many to actually
> list them all, and not all are part of numpy. I know I should be avoiding
> from scipy import *

Which functions? A few from the scipy.special subpackage? "import
scipy" really imports nothing other than numpy under a different
namespace and with some different defaults exposed (for various
historical reasons). You almost never want to do that. If you need
things from one of the subpackages, you will need to import those
subpackages explicitly, e.g. "from scipy import special". That will
take a little more time than importing just numpy, but not as much
time as it would to import from all of the subpackages one by one.

Robert Kern

"I have come to believe that the whole world is an enigma, a harmless
enigma that is made terrible by our own mad attempt to interpret it as
though it had an underlying truth."
  -- Umberto Eco

More information about the SciPy-User mailing list