On Feb 06, 2010, at 11:22 PM, exar...@twistedmatrix.com wrote:

>>I haven't tried to repro this particular example, but the reason is
>>that we don't want to have to call getpwd() on every import nor do we
>>want to have some kind of in-process variable to cache the current
>>directory. (getpwd() is relatively slow and can sometimes fail
>>outright, and trying to cache it has a certain risk of being wrong.)
>
>Assuming you mean os.getcwd():
>
>exar...@boson:~$ python -m timeit -s 'def f(): pass' 'f()'
>10000000 loops, best of 3: 0.132 usec per loop
>exar...@boson:~$ python -m timeit -s 'from os import getcwd' 'getcwd()'
>1000000 loops, best of 3: 1.02 usec per loop
>exar...@boson:~$
>So it's about 7x more expensive than a no-op function call.  I'd call 
>this pretty quick.  Compared to everything else that happens during an 
>import, I'm not convinced this wouldn't be lost in the noise.  I think 
>it's at least worth implementing and measuring.

I'd like to see the effect on command line scripts that are run often and then
exit, e.g. Bazaar or Mercurial.  Start up time due to import overhead seems to
be a constant battle for those types of projects.

-Barry

Attachment: signature.asc
Description: PGP signature

_______________________________________________
Python-Dev mailing list
Python-Dev@python.org
http://mail.python.org/mailman/listinfo/python-dev
Unsubscribe: 
http://mail.python.org/mailman/options/python-dev/archive%40mail-archive.com

Reply via email to