Integrate Python in a C/C++ application

Thomas Heller theller at python.net
Tue May 20 14:49:56 EDT 2003


claird at lairds.com (Cameron Laird) writes:

> In article <Cz9xa.185392$K35.4339125 at news2.tin.it>,
> Alex Martelli  <aleax at aleax.it> wrote:
> 			.
> 			.
> 			.
> >Oh yes!  In particular, I'm really interested in learning
> >what makes you think that embedding is gradually becoming
> >less important wrt extending -- because I have that
> >feeling too but can't really articulate the "why"s.
> 			.
> 			.
> 			.
> Social processes and Python's completeness.
> 
> My perception is a strong one:  I'm quite convinced this is
> true, and objective evidence to the contrary would surpise
> (and interest!) me a great deal.  I'd put a big bet on this
> one.
> 
> It's not for profoundly Pythonic reasons, though; I don't 
> think that the type-class reunification was a monumental
> breakthrough for embedders, or that the multiple Python
> implementations (Jython, Stackless, ...) have somehow stoked
> interest in keeping Python "on top".

It was for me, because it allowed me to write the ctypes module.  With
this module, even rewriting Mark Hammond's PythonService.exe in Python
becomes possible. (PythonService.exe is the main program, written in
C++, for a Windows NT service embedding Python.)

> 
> My first reason, then, has to do with memetics: regression 
> to the mean and tipping-point arguments.  As time goes on,
> a smaller and smaller proportion of programs have been writ-
> ten so as to resist being factored into Python extensions.
> Extension's share will continue to expand, just to catch up
> with the opportunity.  Also, as we improve the documentation
> and capabilities of Python's extensibility, more and more
> programmers will get the point that it's feasible.  The 
> *idea* has nearly reached "critical mass", so that it can
> take over the intellectual landscape.
> 
> The second major reason is simply that Python has become 
> more complete.  A 1993 designer might reasonably default
> to C (or C++), supplemented as necessary.  He wants script-
> ability, so he embeds Python.  Would he turn it inside-out,
> and instead extend Python?  It's unlikely, because at that
> time, it was hard to regard Python as a general-purpose
> language.  Ten years later, we can argue that Python is
> more general-purpose than C!  People can *see* Python as
> the top-level architecture far better than when the library
> lacked networking, OS calls, and so on.

When I discovered Python (IIRC, it was when 1.4 had released, and my
copy of Programming Python still covered 1.3) I *was* looking for a
scripting language for the next version of my application. The current
version (of the app) was still a 16-bit C program, scripted by a custom
scheme interpreter.

As soon as I begun to even implement parts of the top-level GUI stuff in
Python, I felt that writing the main program in Python would be in
order.

So, it seems I cannot tell Alex *why* I had this feeling, but it was the
same.

Thomas




More information about the Python-list mailing list