Any suggestions?

Aahz Maruch aahz at
Sat Sep 23 00:48:25 CEST 2000

In article <8qgev7$oir$1 at>,  <rick_richardson at> wrote:
>> That seems a little odd.  Are these non-trivial projects?  Have you done
>> any work to optimize the Python code?
>I didn't know I could.

Of course you can.  Here's a simple example:

  str = ''
  for word in words:
    str = str + ' ' + word

That code can be easily optimized to

  str = string.join(words)

Every language has its efficient coding tricks; the neat thing about
Python is that once you've gotten a decent handle on its tricks, you can
concentrate on algorithmic improvements -- even if your C code is a
hundred times faster than the Python code, you'll be unhappy as soon as
you hit non-trivial inputs if your C code is O(N^2) and your Python code
is O(NlogN).
                      --- Aahz (Copyright 2000 by aahz at

Androgynous poly kinky vanilla queer het    <*>
Hugs and backrubs -- I break Rule 6

Member of the Groucho Marx Fan Club  --Aahz

More information about the Python-list mailing list