Help: Python for a big commercial project?

Roy Smith roy at panix.com
Wed Apr 10 20:47:07 EDT 2002


Cliff Wells <logiplexsoftware at earthlink.net> wrote:
> Absolutely.  I would not hesitate to use Python for *any* project.

I think one of the keys to a successful large-scale python project is 
understanding its strengths and weaknesses.  Take advantage of the former, 
and don't try to brute-force your way past the latter.

For example, python is not very good at low-level character manipulation.  
If you're parsing text, for example, and are used to typical C-style 
tokenizer loop:

   while (c = getchar()) {
      switch (c):
         blah, blah

and try to translate that directly into python, you'll probably end up with 
something which is slow as a dog (DAMHIKT).  The key is to figure out which 
little bits of your code would benefit most from re-writing them as a C 
module, and doing that.  You may discover that writing 2% of your code in C 
will give you something that's 10 times faster than the pure python 
implementation.  Without having looked at the code, I'm guessing that the 
pickle/cPickle modules fall into this category.

The nice thing is that you can start out by writing everything in python, 
then, once you've got it all working, profile the thing and figure out 
what's the bottleneck.  You can then do a selective C rewite as time 
permits and performance demands.



More information about the Python-list mailing list