In the last days, i've been committed to learn C++ so I can port performance critical methods in my Python apps to it. I found a great site - www.cplusplus.com with a nice tutorial worth a look.
I started reading thru a lot of documentation on how to create Python C modules but all those PyObjects and all made a mess in my head.
Looking in the Python-Ogre (Python bindings for the wonderful Ogre3D engine), I found that they use a new code generator for boost-python called Py++.
I heard a lot about boost and its qualities so I figured out that this was the best option and with Py++ to create the wrapper files it became easier.
The problem was not how to create the wrapper files and generate the modules but and install that bunch of packages and modules on windows was a pain.
What you will need:
- Compiler (I'm using VS2005 Express since its free)
- Platform SDK R2 (Windows headers)
- Python (Of course...)
- 2 eggs ... oops... forget this one
- Boost installer for Windows Easier to install, better than compile yourself.
- GCC-XML
- Pygccxml
The resumed installation procedure is:
- Install the compiler and the platform SDK
- Configure your compiler to use the 'libs', 'includes' and 'bins' from the SDK
- Configure the vcvars32.bat file to add the SDK paths to it so the Compile console finds the headers.
- Run the boost installer, it will download the needed packages from a mirror. I installed the base packages and the Python lib.
- Unpack and run 'python setup.py install' on GCC-XML. In my case, it have not compiled with VC2005 so I unpacked myself and followed the instructions here. Then I compiled using the generated solution file.
- Install the pygccxml package 'python setup.py build install'
- Install the py++ package 'python setup.py build install'
Thats it for now... in my next post I will post some examples and procedures for generating the C++ modules.
Tuesday, May 22, 2007
Subscribe to:
Post Comments (Atom)
4 comments:
Is there a reason you decided to go with C++ instead of C, for the (presumably) small bits of inner-loop code that need optimized? It seems to me that most of the hypothetical advantages that C++ has over C are pretty much obsoleted when you're writing most of your program in Python—the most obvious example being that you don't need an object system in your optimized code because Python provides quite a good one for you.
Check out ctypes, it can be used to load C++ libraries.
It's frequently a simpler, more elegant approach than using wrapper generators.
A caveat: you'll need to use extern "C" to disable C++ compiler name mangling.
Re: Is there a reason you decided to go with C++ instead of C, for the (presumably) small bits of inner-loop code that need optimized? It seems to me that most of the hypothetical advantages that C++ has over C are pretty much obsoleted when you're writing most of your program in Python—the most obvious example being that you don't need an object system in your optimized code because Python provides quite a good one for you.
You can't be serious. That's just a true hater post. Come on now.
C++ has an immense amount of advantages over C -- they're not hypothetical. Furthermore, you can expose your C++ class hierarchy to use IN python, which is very important for interfacing.
I'm the sort of hombre who loves to try hot things. Presently I am manufacturing my private solar panels. I am managing it all alone without the help of my men. I am using the net as the only way to acheive that. I stumbled upon a truly amazing site that explains how to make photovoltaic panels and wind generators. The internet site explains all the steps needed for building pv panels.
I am not exactly sure about how precise the information given there iz. If some guys over here who had experience with these works can have a see and give your feedback in the thread it would be great and I'd really treasure it, cause I extremely lav [URL=http://solar-panel-construction.com/diy-solar-panel-construction-is-it-really-possible]solar panel construction[/URL].
Thanks for reading this. U guys rock.
Post a Comment