Question on Manipulating List and on Python

Chris Angelico rosuav at gmail.com
Thu Sep 29 12:50:49 EDT 2011


On Fri, Sep 30, 2011 at 2:36 AM, Subhabrata Banerjee
<subhagurgaon2011 at gmail.com> wrote:
> And Python seems faster than C++/Java. It is indeed. I also experience
> it.
>

Python compared to Java? Difficult to compare. Python to C++?
Impossible to compare. But performance depends MASSIVELY on
algorithmic quality; if you code the exact same thing in Python and in
C++, you would probably find that the C++ one is faster, but chances
are you're implementing approximately the same thing in two quite
different ways. Or possibly you're using a slow and inefficient
library or third-party function.

I've sometimes written code in one language and directly ported it to
another, and then run both on the same hardware. With most such
experiments, CPython generally doesn't perform all that well, and C or
C++ rocks. But frequently, the C/C++ code is more verbose and more
error-prone than the Python - because Python's biggest boast is not
that it's fast, but that it's *fast enough*, while being easy to work
with. (And every once in a while there's something where I want to use
a pointer to some other variable, and that's a concept that just plain
doesn't work in Python. You have references to objects, but you can't
from one place change another variable, without using some kind of
mutable object that they both reference.)

ChrisA



More information about the Python-list mailing list