[Pythonmac-SIG] What slows down python? (OS X python question)

Donn Cave donn@u.washington.edu
Thu, 11 Oct 2001 14:28:52 -0700


Quoth "David Pennell" <dpennell@guardnet.com>:
| What can make command-line python slow down?
|
| Is it simply too many modules in the home library?
|
| How can you tell what's going on with python, if it's your build?

I have found problems there by tracing system calls.  NetBSD has a
ktrace command, which you'd use most conveniently with the PID of
the python process.  One way to start tracing the PID ahead of time
is to use something like this shell script to exec your program:

runit:
	echo -n "$$: OK? "
	read junk
	exec "$@"

$ sh runit python -c 'print "hello"'
384: OK? <in other window, "$ ktrace -p 384", then hit Return.>
hello
$

<back to other window>
$ kdump
<reams of interesting output.>

The system calls cover all the I/O, which surely accounts for the
vast majority of startup time.  If you don't have ktrace, or something
with "trace" in the name, look for something with "truss" in the name.
(Obviously I haven't been near MacOS X yet.)  You can probably get
time stamps, with the right kdump flags.

For an actual example, that turned up an unnecessary excursion through
the Unicode modules no one had really intended, in a 2.0 beta that was
mysteriously much slower than 1.5.2.

	Donn Cave, donn@u.washington.edu