[IronPython] Announcement: Project to get some CPython C extensions running under IronPython

Paolo Molaro lupus at ximian.com
Wed Oct 17 18:26:36 CEST 2007

On 10/17/07 Curt Hagenlocher wrote:
> On 10/17/07, Paolo Molaro <lupus at ximian.com> wrote:
> > As python extensions use a C API, I don't see how Managed C++
> > would provide source compatibility. Managed C++ would be an ill-advided
> > method, IMHO.
> > [...]
> > You'd have two components: the C API headers and some C code (this is
> > required in any case) is the first. Then you need an assembly that
> > translates from the C API to the IronPython model. You can write this
> > in nice C# + a few dllimports or with the ugly managed C++ (assuming
> > managed C++ can actually consume the python headers).
> >
> MC++ lets you create a single module that contains both "normal" machine
> code and MSIL, and takes care of the transitions between the two.  There's
> no reason you can't compile the existing C code and link it directly with
> the MC++ wrapper -- which is exactly what I originally meant.

The python API requires a couple dozen structure definitions plus a few
dozen dllimport declarations. This can be about 200 lines of trivial
to write declarative stuff.

The rest of the code is likely in the order of 50 K lines, so now ask
yourself: would you rather write

	a) 50 K lines of nice C# code + 200 lines of trivial declarations
	b) 50 K lines of orrible C++ code?

I know what I would answer:)
The managed C++ discussion is focused on avoiding the 200 lines of
trivial declarations, when the issue is the 50 KLOC.

Managed C++ might make sense if you have lots of legacy C++ code you
need to integrate (at least until MS itself will pull the plug on it).
For new code like this case, managed C++ is the wrong tool, IMHO.


lupus at debian.org                                     debian/rules
lupus at ximian.com                             Monkeys do it better

More information about the Ironpython-users mailing list