logo       

Re: [newbie] Question on embedding/extending with boost::python: msg#00318

python.c++

Subject: Re: [newbie] Question on embedding/extending with boost::python

Brett Calcott wrote:
"Dirk Gerrits" <dirk@xxxxxxxxxxxxxxxxxx> wrote:

Chris Heald wrote:
>
[snip]

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)

while (engine_running)
{
for (agents_container:iterator a = agents.begin(); a !=
agents.end(); ++a)
{
// here we call out to python for each agent
(*a).update_yourself_via_python()
update_visual_stuff()
}
}

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.

What I am doing now is different - I am constructng an engine in C++,
making all the agents and world parameters accessible to python, BUT
the update main loop remains entirely in C++:

import engine # boost python module

while engine_running:
engine.cycle()

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?

Regards,
Dirk Gerrits


<Prev in Thread] Current Thread [Next in Thread>
Google Custom Search

News | FAQ | advertise