Programming Habits in Python

Andrew Dalke dalke at acm.org
Wed Dec 13 22:26:02 EST 2000


Keith Ray wrote:
>Could you have put the code for each of those 12 states into separate
>classes, and put instances of those classes into a dictionary where the
>key is the state-id?

You are refering to the mxTextTools example, I presume, and not
the C++/MIX one?

No, I could not.  I think you don't know how mxTextTools works.
It does all the work in C, which makes it fast but precludes
easy calls to Python.  Now, it does allows Python calls, but the
peformance would be even worse, and I needed that performance.
It ended up, btw, that mxTextTools was faster than Python's
readlines solution *and* let me parse \n, \r\n and \r line
endings.  (I believe the speed comes from using Boyer-Moore
because I'm actually looking for a line which starts with a
given text, so there's more text it can know to skip.)

                    Andrew
                    dalke at acm.org






More information about the Python-list mailing list