[C++-sig] Re: [newbie] Question on embedding/extending with boost::python

Dirk Gerrits dirk at gerrits.homeip.net
Fri May 30 21:45:58 CEST 2003


Brett Calcott wrote:
> "Dirk Gerrits" <dirk at gerrits.homeip.net> wrote:
> 
>>Brett Calcott wrote:
>>
>>>I had previously embedded python in my c++ app so that I could
>>>script my agents, but the result was very slow as this effectively
>>>did this (vastly simplified)
>>>
[snip]
>>>
>>>The calls to python are in the inner loop and this is slow.
>>
>>Well I suppose you could expose a visual_stuff_updating_iterator to
>>Python, but extending is of course a much easier and cleaner.
> 
> 
> Not sure I follow what you mean here..

Well I just thought you could let Python drive the loop by exposing the 
agents.begin()/end() range as an iterator, possibly with the visual 
stuff updating built into it. But if it would be more efficient at all, 
it would probably not be by much. As I said, your current solution is 
much nicer (and efficient).

[snip]

>>I'm not sure I follow. Is engine.cycle() still doing a
>>a->update_yourself_via_python() for every agent? Then where's the
>>speedup compared to the embedded approach?
>>
> 
> No, it's not. The engine.cycle() function never calls back to python.
> 
> Let me try and clarify.
> 
[snip]
> 
> To summarise -- that big change is in how I look at python. Before, I
> saw C++ as a serious development framework, and python as a scripting
> language for doing the little bits of my app that I wanted to change
> quickly. Now, I see python as an incredibly fast development framework,
> and C++ as something to make the computationally intensive bits of my
> app go faster.
> 
> So I things have sort of been stood on their head.  I still love C++,
> but I can make stuff happen so much more quickly in python.

I think most (all?) using this SIG can agree to that. :)

Regards,
Dirk Gerrits






More information about the Cplusplus-sig mailing list