[Python-Dev] C++ for CPython 3? (Re: str.count is slow)
Greg Ewing
greg.ewing at canterbury.ac.nz
Wed Mar 1 05:28:25 CET 2006
Fredrik Lundh wrote:
> should we perhaps switch to (careful use of) C++ in 3.0 ?
I worry that if the Python core becomes dependent
on C++, it will force all extensions to be written
in C++, too.
Not only is this inconvenient for people who don't
know C++ or prefer not to use it, but I suspect
this would lead to some severe interoperability
problems.
On most platforms, C code will happily link to
just about anything else, but in my experience,
C++ code will only interoperate with other C++
code when it's compiled by exactly the same
compiler and uses the same runtime system.
For another thing, I'm not sure that C++
polymorphism is flexible enough to implement
Python's style of polymorphism. Think of all
the tricks we play with type objects -- allocating
them on the heap, extending them dynamically at
runtime, etc. In C++, classes aren't even available
as program-accessible entities.
So we'd end up implementing our own form of
dynamic dispatch anyway, and it would probably
look a lot like the current C-based type objects.
I don't see that C++ would help much.
--
Greg
More information about the Python-Dev
mailing list