[C++-sig] Announce: PyBindGen 0.11 released
To integrate some recent contributions, here's a new PyBindGen 0.11 release. About: PyBindGen is a Python bindings generator written in Python. Download: http://code.google.com/p/pybindgen/ Summary of changes: - Generate code that supports GCC's -fvisibility=hidden - Add rudimentary support for std::map containers - Some inplace numeric operators now supported (J. Michael Owen) - Partial sequence protocol support: __len__, __getitem__, and __setitem__ (J. Michael Owen) - Partially support pointer-to-container parameters - Call traceback.extract_stack() less often (faster on win32) - No need for GIL locking in attribute setters (thanks Stuart Stock) - Allow wrapping enum given list of (name, value) pairs - New foreign_cpp_namespace option, for wrapping classes outside our module's C++ namespace - Add a docstring parameter to CppMethod constructor (Robin Gilks) Also add a docstring parameter for CppClass - Better support for typedefs - Implement support for enum reference parameters - Add support for size_t "by-value" type -- Gustavo J. A. M. Carneiro INESC Porto, Telecommunications and Multimedia Unit "The universe is always one step beyond logic." -- Frank Herbert ___ Cplusplus-sig mailing list [email protected] http://mail.python.org/mailman/listinfo/cplusplus-sig
[C++-sig] Boost.Python is slow?
Hello everyone! I'm currently embedding Python and have a problem. I have a
struct (point) which looks like
struct TPoint
{
int x, y;
};
And I want it to be usable from Python. I made it in two ways: the first one
was writing all the warpping by myself according to Python/C API, and the
second was wrap it with Boost.Python. So it looks like
class_("TPoint")
.def_readwrite("x", &TPoint::x)
.def_readwrite("y", &TPoint::y);
It wraps ok but here is a problem: I create a huge (100 items) list of
objects of that type:
def cr_fig(n):
res = []
while n>0:
res.append(TPoint())
n -= 1
return res
And then when I use a simple function which just increments the x member of
every object, this function takes about 4 seconds to process the whole list
(100 items) of Boost-wrapped objects and less than a second to process
objects of my own wrapping! How this can be possible? Is Boost.Python much more
slower than Python itself?
Regards, Artyom Chirkov.
___
Cplusplus-sig mailing list
[email protected]
http://mail.python.org/mailman/listinfo/cplusplus-sig
Re: [C++-sig] Boost.Python is slow?
For something like this, it would be better to write a function that performs the operation on the million+ Points in C++ and expose that function to Python. This would be a better alternative to both using Boost.Python or wrapping it by hand. Kamal > From: [email protected] > To: [email protected] > Date: Mon, 13 Jul 2009 06:19:57 +0400 > Subject: [C++-sig] Boost.Python is slow? > > Hello everyone! I'm currently embedding Python and have a problem. I have a > struct (point) which looks like > > struct TPoint > { > int x, y; > }; > > And I want it to be usable from Python. I made it in two ways: the first one > was writing all the warpping by myself according to Python/C API, and the > second was wrap it with Boost.Python. So it looks like > > class_("TPoint") > .def_readwrite("x", &TPoint::x) > .def_readwrite("y", &TPoint::y); > > It wraps ok but here is a problem: I create a huge (100 items) list of > objects of that type: > > def cr_fig(n): > res = [] > while n>0: > res.append(TPoint()) > n -= 1 > return res > > And then when I use a simple function which just increments the x member of > every object, this function takes about 4 seconds to process the whole list > (100 items) of Boost-wrapped objects and less than a second to process > objects of my own wrapping! How this can be possible? Is Boost.Python much > more slower than Python itself? > > Regards, Artyom Chirkov. > ___ > Cplusplus-sig mailing list > [email protected] > http://mail.python.org/mailman/listinfo/cplusplus-sig _ Attention all humans. We are your photos. Free us. http://go.microsoft.com/?linkid=9666046___ Cplusplus-sig mailing list [email protected] http://mail.python.org/mailman/listinfo/cplusplus-sig
Re: [C++-sig] Boost.Python is slow?
> For something like this, it would be better to write a function that performs the operation on the million+ Points in C++ and expose that function to Python. > This would be a better alternative to both using Boost.Python or wrapping it by hand.> > KamalProbably it would, but the point is to add some scriptability to the code so that I could do (almost) whatever I want with data.By the way, folks from Boost-users list asked for compilable examples and here they are: http://www.filefactory.com/file/ahda0d8/n/_export_Boost_vs_pure_Python_7z (if someone is interested)I got these results in the test:Getting boost.python point 100 times:0.302821578459Getting Python point 100 times:0.121208008078Setting boost.python point 100 times:0.373980616451Setting Python point 100 times:0.109051436823Increasing boost.python point 100 times:0.708493801882Increasing Python point 100 times:0.20538183019The numbers are time in seconds taken to accomplish calculations.___ Cplusplus-sig mailing list [email protected] http://mail.python.org/mailman/listinfo/cplusplus-sig
