c(++)python?

Tim Peters tim.one at home.com
Sat Jan 27 02:20:54 EST 2001


[Stephen Boulet]
> ...
> Why is the most popular implementation of python in C? A novice
> programmer (like myself) might think:  "python is itself an
> object-oriented language, so it would make sense to implement it in
> another object-oriented language."
>
> Is this in fact the case, or was c++ not standardized/mature enough
> when python first came out?

Even ANSI C (1989 flavor) wasn't implemented widely enough when Python came
out, so Python in fact stuck to a subset of K&R C.  It wasn't until last
year (2000) that we first insisted people use an ANSI C (1989 flavor)
compiler!  Before then, the code base was littered with macro tricks to let
people keep using K&R C compilers.

Given the number of odd platforms Python is ported to, C++ would still be a
major gamble.  If history repeats, around 2010 we'll insist that people
finally use a 1999-flavor ANSI C compiler (although there's some doubt that
vendors will actually implement all of C99).

BTW, implementing an OO language in another OO language has its own
pitfalls, and especially if the OO models don't coincide exactly.  You end
up writing your own runtim code to do, e.g., method lookup anyway.  And for
interoperability with legacy code, you can't let the implementation language
decide object storage layout either.  Etc.  I'd rather do *anything* in C++
than in C, but in the case of implementing Python it would be more for "C++
is a tastier flavor of C" reasons.

still-if-you-reimplement-python-in-c++-please-post-the-patch-
    to-sourceforge<wink>-ly y'rs  - tim





More information about the Python-list mailing list