difference between import from mod.func() and x=mod.func()

Fredrik Lundh fredrik at pythonware.com
Tue Jun 20 04:27:41 EDT 2006


Hari Sekhon wrote:

> What is the difference in terms of efficiency and speed between
>
> from os import path
>
> and
>
> import os
> path=os.path

the only difference is that the former only sets the "path" variable, while the
latter leaves both "os" and "path" in your namespace.

> I would think that the import from would be better, just curious since I
> read somewhere on the web, some guy's code tutorial where he did the
> latter and said it was for efficiency/speed.

sounds like "uneducated premature optimization" to me.

</F> 






More information about the Python-list mailing list