Painfully slow startup

David Bolen db3l at fitlinxx.com
Mon Sep 11 18:26:06 EDT 2000


markscottwright at hotmail.com writes:

> Is python typically very slow when starting up?  When I compare a
> simple 'hello world' application against perl, python is 2 orders of
> magnitude slower on startup.  It's quite noticable - even the smallest
> scripts take more than 3 seconds to load and run (this is on a 500mhz
> Pentium III running Windows2000).  I'm considering embedding python in
> one of our products, but the application is time-sensitive enough that
> a 3-4 second load time is unacceptable.  I'm using Python 1.5.2 (from
> the Win32 installer - I haven't re-compiled it myself or anything).  I
> suspect that my version of python must be configured incorrectly - does
> anyone have any clues?

Well, as a point of comparison, running your test program on my
machine yielded a pretty consistent 120-130 for Python and 50-60 for
Perl.  This is under WinNT 4.0 on an ~400MHz PIII with Python 1.5.2 as
distributed as a win32 binary.  So if there is something, it might be
more the system environment than Python specifically.  Compared to
Perl, Python does do more searching upon startup for site files and
building the library path and such not that has been discussed here
previously, but it shouldn't be as bad as you note.

Is this consistent for you?  I did find that on my first test, while
Python gave 120, Perl gave 1062, because I hadn't run it yet.  After
that, it was probably cached and loaded at the faster rate.

In 1.5.2, Python also pulls in winmm.dll, which I believe others have
posted as being a particularly slow loader in some environments.
That's changed in 2.0 (not positive about 1.6), so you might test that
just to see if it improves things.  On my same system, 2.0 (current
version from CVS) loads in about a tick count of 90-100, so about 75%
of the time it takes to use 1.5.2.  But I'm not sure what other
concrete things to try offhand in terms of your Windows configuration.

With respect to your application, realize also that when you embed
Python you really only have the primary startup cost once, along with
your application startup.  Feeding information to Python to execute
shouldn't be anywhere near the same overhead as startup.

--
-- David
-- 
/-----------------------------------------------------------------------\
 \               David Bolen            \   E-mail: db3l at fitlinxx.com  /
  |             FitLinxx, Inc.            \  Phone: (203) 708-5192    |
 /  860 Canal Street, Stamford, CT  06902   \  Fax: (203) 316-5150     \
\-----------------------------------------------------------------------/



More information about the Python-list mailing list