python speed

Jorgen Grahn grahn+nntp at snipabacken.dyndns.org
Fri Jan 6 18:52:31 EST 2006


On Thu, 29 Dec 2005 00:41:58 +0100, Andreas Kostyrka <andreas at kostyrka.org> wrote:

[on research supposedly proving that Python is faster than C, Java and
Fortran and assembly]

> Well, it's easy enough to "prove".
>
> Take one aspect of Python: Automatic memory management via reference
> counting.
>
> Now, while it's certainly possible to implement exactly what Python does
> in C++ (both are turing complete, ...), the normal and idiomatic way is
> to have APIs that care about object ownership.

Your discussion is interesting but a bit misleading, because most function
calls in C++ don't involve ownership issues. Most parameters are passed by
value (for reasonably small things, copying on a warm stack is bloody fast!)
or by const reference, with the understanding that the callee doesn't steal
or borrow a reference to the object. Or, the whole thing is inlined.

Yes, it sometimes happens that you have to have weirder things happen to
your objects -- but only to a tiny fraction of them, not all of them as in
Python. I cannot see how that would make Python, in general, faster than
C++.

> The normal idiomatic way
> is relevant, as third-party libraries usually force one to develop this
> way.

I never use third-party C++ libraries, but I can see how an overly complex,
obsolete and badly designed API (MFC, anone? Or CORBA monstrosities.) could
complicate this a lot. /This/ is an area where C++ and similar languages
lose to Python -- you have to be an expert to write reusable C++ APIs which
don't suck!

/Jorgen

-- 
  // Jorgen Grahn <grahn@        Ph'nglui mglw'nafh Cthulhu
\X/     snipabacken.dyndns.org>  R'lyeh wgah'nagl fhtagn!



More information about the Python-list mailing list