Python performance notes...
Brett g Porter
BgPorter at NOacmSPAM.org
Thu May 25 21:29:13 EDT 2000
"Courageous" <jkraska1 at san.rr.com> wrote in message
news:392DBEAB.B5147578 at san.rr.com...
> > Except your version will run *much* slower given a large dataset.
> > map's are implemented using balanced tree algorithms, while the python
> > example is using a hash table.
> The SGI hash_map<> would have been a better choice.
> STL maps are an example of trying to cram in the
> kitchen sink, IMO.
hash_map woulda been good, yes, but I don't have the SGI STL on my machine.
I haven't instrumented the code, but a quick eyeball comparison of the two
using the full text of 'Crime and Punishment' shows the C++ version on my
machine to be at least as fast as the Python, balanced trees or not.
I took Aahz' original point to be that since the Python version could be
written significantly faster than a C version, there was a class of problems
where that metric alone makes Python the clear winner. I was more interested
in the speed of development issue, which for this one case, choosing C++
allowed me to write the solution as quickly as I might have in Python,
without sacrificing execution speed.
More information about the Python-list