On 7 Feb 2010, at 05:27, exar...@twistedmatrix.com wrote:

> Do you know of a case where it's actually slow?  If not, how convincing 
> should this argument really be?  Perhaps we can measure it on a few platforms 
> before passing judgement.

On Mac OS X at least, system calls are notoriously slow. I think it has to do 
with Mach overhead, or something…

$ arch -arch ppc /usr/bin/python2.6 -m timeit -s 'def f(): pass' 'f()'
1000000 loops, best of 3: 0.476 usec per loop
$ arch -arch ppc /usr/bin/python2.6 -m timeit -s 'from os import getcwd' 
'getcwd()'
10000 loops, best of 3: 21.9 usec per loop
$ arch -arch i386 /usr/bin/python2.6 -m timeit -s 'def f(): pass' 'f()'
1000000 loops, best of 3: 0.234 usec per loop
$ arch -arch i386 /usr/bin/python2.6 -m timeit -s 'from os import getcwd' 
'getcwd()'
100000 loops, best of 3: 14.1 usec per loop
$ arch -arch x86_64 /usr/bin/python2.6 -m timeit -s 'def f(): pass' 'f()'
10000000 loops, best of 3: 0.182 usec per loop
$ arch -arch x86_64 /usr/bin/python2.6 -m timeit -s 'from os import getcwd' 
'getcwd()'
100000 loops, best of 3: 11 usec per loop

For maximum reproducibility, I used the stock Python 2.6.1 included in Mac OS X 
10.6.2. In other words ‘os.getcwd()’ is more than fifty times as slow as a 
regular function call when using Mac OS X.

--

Dan Villiom Podlaski Christiansen
dan...@gmail.com

Attachment: smime.p7s
Description: S/MIME cryptographic 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