Why is python not written in C++ ?

Christian Heimes lists at cheimes.de
Mon Aug 9 14:27:20 EDT 2010


> I highly doubt the Python source would build with a C++ compiler.
> 
> C++ is "'mostly' 'backwards' compatible" with C insofar as you can
> pretty easily write C code that is also legal (and semantically
> equivalent) C++.  But if you don't actively try to write code that is
> compatible with both languages, chances are the C code will invoke one
> of those "'minor' 'backwards' incompatibilies", the most common one
> being failure to cast a pointer.

Indeed:

g++ -pthread -c -fno-strict-aliasing -g -O2 -DNDEBUG -g -fwrapv -O3
-Wall   -I. -IInclude -I./Include   -DPy_BUILD_CORE -o Parser/parsetok.o
Parser/parsetok.c
Parser/parsetok.c: In function 'node* parsetok(tok_state*, grammar*,
int, perrdetail*, int*)':
Parser/parsetok.c:251: error: invalid conversion from 'void*' to 'char*'
make: *** [Parser/parsetok.o] Error 1

Beside from several invalid conversions Python could most probably be
compiled with a g++ compiler. I once worked on a patch to fix the
conversion issues but Martin argued against it. There isn't really a
point in cluttering the source with type casts.

Christian




More information about the Python-list mailing list