Re: type casting and c++

Guido van Rossum (Guido.van.Rossum@cwi.nl)
Sat, 19 Jun 1993 10:55:39 +0200

> This sounds like a good argument for translating Python into C++.
> Here's another: that business of explicitly managing reference counts
> could be greatly simplified using C++ constructors and destructors.
> This would make the job of writing extension modules less error prone.

I tried setting up a scheme for automatic reference counting C++ once
and soon found out that it incurs a lot more overhead than the way
it's done manually in C now. The problem is that in many situations
you don't need to change a reference count because you don't
permanently store a copy of a pointer, you only "peek" at it. A
simple-minded reference-counting pointer type in C++ won't know this
and will add referece count adjustments in many more places than
necessary. When this happens at the lower levels it will really slow
things down.

> Ignore for a moment the fact that it would be a lot of work,
> and consider this: Python is written in C because C is ubiquitous.
> Since Python began, C++ has become much more widely available.
> There are now multiple PC and Mac compilers, and GNU seems to cover the
> Unix platforms. Is C++ now sufficiently widely available that converting
> Python to C++ makes sense?

I have my doubts. C++ is more widely available, but it is not by any
measure "ubiquitous". It is also not yet stable (templates?
exceptions? multiple inheritance?) It is also bigger, slower, and
harder to learn. Some people even consider it as a failure because it
leaves most of C's unsafe features intact.

I like to see Python as a "democratic" language, available for all.
(That's why I distribute Mac and PC binaries -- most owners of those
machines don't have *any* compiler.) Requiring people to acquire C++
before building Python is one more burden and will surely slow down
Python's acceptance.

But, feel free to prove me wrong...

--Guido van Rossum, CWI, Amsterdam <Guido.van.Rossum@cwi.nl>