Is Python overhyped (just like Java)?
Delaney, Timothy C (Timothy)
tdelaney at avaya.com
Mon Mar 31 16:53:56 EST 2003
> From: David Abrahams [mailto:dave at boost-consulting.com]
>
> Alex Martelli <aleax at aleax.it> writes:
>
> > Thanks to the excellent support given for these tasks by
> the standard
> > library, the C++ source is ONLY twice as big as the Python
> source for
> > the same job (a more usual ratio is around 5:1). This
> holds for both
> > the simplest versions, and the slightly more complicated ones with
> > somewhat better optimization. The runtimes on my box
> (Linux Mandrake
> > 9.0, gcc 3.1, Python 2.3) are, when the programs are run on
> the 4.4 MB
> > of the "King James Bible" in plain ASCII text: 17.4 seconds for the
> > simplest C++, going down to 15 with optimizations; 11.2 seconds for
> > the simplest Python, going down to 8.1 with optimizations (CPU times
> > are in very similar ratios). Of course, this basically reflects the
> > excellence of Python's intrinsics (dictionaries, lists, strings)
> > versus the lesser quality of C++'s library implementation (maps,
> > vectors, strings) -- with different implementations, you may see
> > different ratios.
>
> Really? Are you sure that time wasn't sunk into I/O? "Read all the
> lines from a file" is a primitive in Python, but not in C++.
>
> Also, it's only fair to point out that C++ doesn't have one library
> implementation -- each compiler comes with its own. Which
> implementation(s) were you testing? Oh, I see it was probably
> libstdc++ that comes with gcc 3.1. Well, IIRC GCC-3.1 was well known
> to optimize poorly (it took them some time to figure out how to
> integrate all the new optimizations that came in with GCC-3, and they
> actually made things slower for a while), and I wouldn't exactly say
> that libstdc++ is the fastest implementation.
I think if you'll read the above, you will notice that Alex says exactly the same thing "...with different implementations, you may see different ratios."
Also, "read all the lines from a file" is not a primitive in Python - it's a method call ... *and* it is written in C. Obviously there could be as good an implementation in C++ on the same platform - whether there could be a *better* implementation is another question.
Tim Delaney
More information about the Python-list
mailing list