Python performance notes...

Bjorn Pettersen bjorn at roguewave.com
Sat May 27 14:19:02 EDT 2000


Moshe Zadka wrote:
> 
> On Thu, 25 May 2000, Brett g Porter wrote:
> 
> > > So?  What's your point?  Try writing the following code in C:
> > >
> > >
> > > How long did it take you?  Did it run as fast as the Python code?  Was
> > > the overhead of the two loops here really a significant factor?
> >
> > here it is in C++. Took me about the same amount of time it woulda taken me
> > to write it in Python, actually...
> > Your point is well taken, nonetheless...
> >
> > // splitter.cpp : Defines the entry point for the console application.
> > //
> >

[snip]

> 
> Well, of course, it is much longer in C++, but just for the heck of it,
> here's the real challenge: change it so you'd print
> 
> word lineno lineno .....
> 
> And the words have to be sorted.
> 

[snip]

> (It took me 3 minutes to take Aahz's script and change it, and I had one
> bug: forgot to import sys and string)
> 
> In 1 more minute, it is possible to change the definition of a word to "a
> consecutive alphabetic characters". In 30 more seconds, it is possible to
> make strings case insensitive, and 30 more seconds to disregard "_"s.
> 
> How much time would it take in C++?
> 
> Remember that map<string, vector<int>> is invalid.

but map<string, vector<int> > isn't... but let's not get into (yet
another) language contest.  There are some things C++ is good for, and
there are some things Python is good for -- and it's easy enough to
embed a Python interpreter in a C++ program or extend Python with a C++
module that the whole point is moot anyway.

--bjorn




More information about the Python-list mailing list