Advice needed for Phython embedding

Martins1

31-12-2006 10:09:54

Hello!

I have a project, which uses C++ and Ogre3d (Eihort) together
with CEGUI (GUI), Newton (Physics), RakNet (Networking), OpenAL (sound),
OIS (input system). It is quite far underway, but I feel that coding in C++
slows me down and I need some more rapid development alternative.

As long as I do not intend to rewrite everything, I am planning to try to code
upcoming things in python. So I think that I want to embed Python in C++
(rather than use plain Python and import Ogre3d). Other thing is that
I would like to have direct access to Ogre3d from my Python scripts,
but not neccesserily to other modules like CEGUI, Newton, Raknet, etc.

Could you recommend me how to start? Should I use Python-Ogre bindings?
Can I use them with Eihort? Will I be able to use any kind of
JIT compiler with my setup? May be you could point me to some
open source projects that use this setup?
And I am really eager to use Stackless Phython version (http://www.stackless.com/). Is it possible with Python-Ogre?

Please, give your opinions and advices!

roman.yakovenko

31-12-2006 11:24:18

So I think that I want to embed Python in C++

You don't have a lot of choices: Boost.Python is the only "high level" solution
that allows you to embed Python within C++

Could you recommend me how to start?
http://boost.org/libs/python/doc/tutori ... dding.html

Should I use Python-Ogre bindings?
It will make sense but not a must.

Can I use them with Eihort?
The next release will include most of functionality found in 1.4 version

Will I be able to use any kind of JIT compiler with my setup?
What do you mean?

And I am really eager to use Stackless Phython version (http://www.stackless.com/). Is it possible with Python-Ogre?


I am not sure, Boost.Python is not thread safe:
http://boost.org/libs/python/doc/v2/faq ... eadsupport

Martins1

31-12-2006 13:39:59

So I think that I want to embed Python in C++

You don't have a lot of choices: Boost.Python is the only "high level" solution
that allows you to embed Python within C++



Ok, this looks like what I am going after.


Can I use them with Eihort?
The next release will include most of functionality found in 1.4 version


Do you know when we could get hands on the next release. Does it mean,
that there is no way to use Python-Ogre bindings (at least partial support)
with Eihort?


Will I be able to use any kind of JIT compiler with my setup?
What do you mean?


I am just thinking if I will be able to speed up Python execution by
compiling it into native code.

Istari

31-12-2006 19:48:51

Stackless does not use system threads so the fact that Boost::Python is not thread safe is not an issue.
In my experience most precompiled Python extension modules will work without modification/recompilation with Stackless.

The only modules that have given me difficulties are modules like the Psyco http://psyco.sourceforge.net/ JIT compiler
since it depends on the Python frame struct being a certain way (and Stackless' frames are different from C/Python's).
But these modules can usually be compiled using the Stackless libs and headers without problems and will then work as expected.

roman.yakovenko

01-01-2007 06:10:11

Do you know when we could get hands on the next release. Does it mean,
that there is no way to use Python-Ogre bindings (at least partial support)
with Eihort?


I think Adny will release the bindings pretty soon. We have 2 minor problems that should be resolved.

Martins1

01-01-2007 15:56:48

Cool, thanks for tips everyone! And happy New Year! :)

roman.yakovenko

02-01-2007 06:17:34

Stackless does not use system threads so the fact that Boost::Python is not thread safe is not an issue.

You are right: http://www.stackless.com/wiki/BoostPython
Thanks for an explanation

roman.yakovenko

02-01-2007 19:16:59

Interesting example of embedding Stakless Python in C++, using Boost.Python:

http://svn.python.org/view/stackless/sa ... iew=markup

The interesting part is that this code is part of a game project that uses
Ogre as graphic engine.

OvermindDL1

03-01-2007 00:06:40

I embed Python in many things, have made quite a few helper functions and a main class to help. I have also embedded stackless and have found out that if you are switching with a C stack on it, it massively slows down from a pure python standpoint (on the order of over twenty times). That watchdog example also uses it in a pre-emptive way, which, although is a little easier to program for, slows it down further. If you want any help in embedding either (and yet I use boost::python as well), code, etc., then you can catch me on GTalk most of the time, same name there as in this forum (OvermindDL1), or on my website.