[Python-Dev] Tutorial: Brief Introduction to the Standard Library

Michael Chermside mcherm at mcherm.com
Mon Dec 1 14:00:30 EST 2003

Raymond> - timeit (because it answers most performance questions in a
Raymond>   jiffy)

Skip> -1.  Newbies should probably not be worried about performance too
Skip> much.  In addition, I think most performance questions are deeper
Skip> than those which can be answered by timeit (think naive O(n^2)
Skip> algorithms).

Skip is right on both counts: newbies DO worry too much about performance,
and they WON'T be able to think deeply about performance issues like how
an algorithm scales (unless they're new to Python but not to programming).
But I still agree with Raymond that timeit should be included.

The fact is, newbies ARE going to worry too much about performance,
whether we want them to or not. And a VERY frequently asked question
on c.l.py is "what's the fastest way to do X". IMHO, learning to answer
this kind of question themselves is MORE important than learning not to
ask the question when it isn't needed -- just like learning to use the
interactive interpreter to answer "does the syntax X work?", it makes
them more self sufficient, and therefore more self confident.

So I'd say DO include a (brief!) tutorial example on using timeit. But
perhaps craft the example so it shows two approaches, one readable
and one obscure, and the obscure one is shown to be FASTER but not
MUCH faster, and is therefore DROPPED in favor of the more readable.
(Hey... rigging the problem set in order to model good practices is an
old teacher's trick I've used often.)

And having piped up with my own 2c, I'd better pay up. Raymond... if
you're working on this and need help, send me an example or two of other
modules (so I can try to follow your style) and I'll volunteer to write
one for timeit.

-- Michael Chermside

More information about the Python-Dev mailing list