Help: Python for a big commercial project?

Cameron Laird claird at starbase.neosoft.com
Thu Apr 11 10:39:12 EDT 2002


In article <roy-EB08BB.20470710042002 at news1.panix.com>,
Roy Smith  <roy at panix.com> wrote:
			.
			.
			.
>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 
			.
			.
			.
Let me reinforce this message.

Python is indeed "not very good at low-level character
manipulation" (and other operations) *in "typical C-style"*.
It FREQUENTLY is the case, though, that rewrites in good
Python style result in code which is more maintainable, only
a fraction as large in lines-of-source-code, and, remarkably,
at least as fast as the hand-coded C.  Why and how this latter
is possible have been explained here often in the past; I'll
abbreviate the details by just saying that Python's run-time
library is itself written in C (at least for conventional 
CPython), and supports many of the actions programmers most
need.
-- 

Cameron Laird <Cameron at Lairds.com>
Business:  http://www.Phaseit.net
Personal:  http://starbase.neosoft.com/~claird/home.html



More information about the Python-list mailing list