2008/11/1 Paul Melis <[EMAIL PROTECTED]> > Gustavo Carneiro wrote: > > > > There's an interesting question about whether it's better to use > > boost.python or SWIG. I've been using boost.python for years, so I > > have a lot invested in it, but if I were starting from scratch, I > > might consider using SWIG because it gives you the flexibility to > > generate wrappers for languages other than Python. > > > > > > On the other hand, SWIG generates ugly and inneficient code, at least > > for the Python case. > I'd like to see proof of the claim that SWIG's wrapper code is > inefficient. In my experience it is not more inefficient than what, for > example, boost.python via Py++ provides.
I don't know how boost.python works, but I know that, in manually wrapped code, when calling a method Python does exactly one dictionary lookup method_name -> method_object, while with SWIG wrappers there are always two lookups method_name -> method_object, then functiona_name -> function_object. In addition, at least one python opcode has to be interpreted between method and function invocation. "inefficient" is a subjective term and I should not have used it, but I can state with almost certainty (not having measured it) that manually wrapped code (or pybindgen generated code, for that matter, but I don't mean boost.python because i don't know it well enough) is faster than SWIG generated code. I am not going to argue whether the difference is substantial for practical uses, I don't know, I just argue that the difference exists. Regards, -- 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 Cplusplus-sig@python.org http://mail.python.org/mailman/listinfo/cplusplus-sig