[Tutor] [FYI] Good source of info on relative efficency of various
string, list, etc. methods (and much more)
Brian van den Broek
bvande at po-box.mcgill.ca
Tue Apr 27 12:33:49 EDT 2004
Hi all,
I have a recommendation for other's learning Python.
Last week I posted a query essentially asking about the relative
efficiency of several approaches to dealing with some data.
(http://mail.python.org/pipermail/tutor/2004-April/029329.html) I received
helpful advice, but I've since found a very handy presentation of these
sorts of issues.
The 15pp or so section on Optimization in Chapter 17 of Python in a
Nutshell (http://www.oreilly.com/catalog/pythonian/) provides a very
readable survey of the computational costs of a number of methods for
processing Python objects. The math and computing theory involved is very
low level (no NP-completeness or anything like that :-) ). While it quotes
the Knuth nugget about premature optimization and evil, it provides what
seems to me to be enough information to guide rational choice without so
much detail as to make you likely to spend time chasing a 0.41%
performance gain.
Beyond the particular section mentioned, I recommend this text in the
strongest terms. I'd worked through Learning Python and while great in
that is is discursive, it is not too good as a "quick, how's that work
again?" text. (No slight; that's not its job.) If, like me, you prefer a
physical book to reading docs on the screen, Nutshell is a great text --
for a quick reference it is remarkably readable! (In the few days since
amazon finally came through, several queries that might well have ended up
as tutor posts were quickly resolved by the text.)
Hope that helps some other newbies.
Best to all,
Brian vdB
More information about the Tutor
mailing list