Basic import Questions (with bonus profiling question)

Fredrik Lundh fredrik at pythonware.com
Thu Aug 31 13:42:17 EDT 2006


Gregory Piñero wrote:

>> several seconds?  sounds bad.  what does the following script print on
>> your machine?
>>
>>         import time, subprocess, sys
>>
>>         t0 = time.time()
>>         for i in range(10):
>>             subprocess.call([sys.executable, "-c", "pass"])
>>         print time.time() - t0
> 
> It prints 1.92199993134
> What does that mean?

that it takes just under two seconds to start the interpreter ten times. 
  not stunningly fast, but not too bad.

> By the way, I thought I was importing just a file path from a module
> but like you said it was importing the entire module.  I got rid of
> that import statement and the time dropped from 7 seconds to 1.5
> seconds.

what module is this?  if it takes 5.5 seconds to import a single module, 
something isn't quite right.

</F>




More information about the Python-list mailing list