Python pyc/pyo (Was: Inflation)

Bernardo Innocenti bernie at codewiz.org
Fri Jul 6 21:19:34 EDT 2007


Mike C. Fletcher wrote:

> My understanding is that slowdown is seen due to large number of stats 
> during module import.

I made a few experiments and it turns out that, on a slow B2, it
takes only 182ms to stat all the 2500 files in /usr/lib/python2.5.

I also analyzed what happens when we do "python -c 'import gtk'",
which takes as much as 1.58 seconds on B2 with warm caches.

We do very few syscalls:

 332  stat()
 608  open()
 263  read()
 135  mmap()

I would call this quite affordable and inconsistent with the very
long time it takes to import gtk.

The C application gtk-demo starts in 0.16s on the same hardware,
so the huge slowdown is either in the gtk bindings or in the
python interpreter.

-- 
   // Bernardo Innocenti
 \X/  http://www.codewiz.org/



More information about the Devel mailing list