Re: [C++-sig] new to python; old to C++

2008-11-01 Thread Roman Yakovenko
On Sat, Nov 1, 2008 at 3:32 AM, Alan Baljeu <[EMAIL PROTECTED]> wrote:
> My first impression of Py++ is that it generates stuff for Boost.Python to 
> use to connect Python to C++.  To get it going I also need to introduce GCC, 
> and probably Cygwin.  That seems like a lot of layers.  Does this not make 
> for a complicated system, with a lot to learn?

Where did you read this. Py++ has dependency on GCC-XML, not on GCC,
neither on cygwin.

The following URL explains how to install it:
http://gccxml.org/HTML/Install.html

> I'm looking for small, simple tools.  Feel free to persuade me on Py++, if 
> you still think it's the way to go.

It is up to you. Py++ is not simple and it takes day or two to learn
to operate it.
But you don't have. If you just start with Boost.Python you still can use it:
http://language-binding.net/pyplusplus/documentation/tutorials/pyplusplus_gui.html

and save a lot of time.

-- 
Roman Yakovenko
C++ Python language binding
http://www.language-binding.net/
___
Cplusplus-sig mailing list
Cplusplus-sig@python.org
http://mail.python.org/mailman/listinfo/cplusplus-sig


Re: [C++-sig] new to python; old to C++

2008-11-01 Thread Greg Landrum
On Sat, Nov 1, 2008 at 4:48 AM, Alan Baljeu <[EMAIL PROTECTED]> wrote:
>
> It was a personal question.  Do you specifically do much wrapping stuff or 
> not?  I'm
> trying to gauge your approach compared to how much you do it.  I mean, if I 
> had
> to wrap one C++ function I would of course use the Python API.  If I had to 
> grab 2000
> classes, I would look for something else to help.  What's the breaking point? 
>  How
> quickly does it go for you?

People are obviously going to have different pain points. I use
straight boost.python to wrap C++ classes and functions, not any of
the wrapper generators like SWIG or Py++. I find that doing things by
hand helps me end up with a more "pythonic" wrapper. If I had to deal
with a large existing class library, I'd probably go a different route
and use a generator.

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.

an aside: you do not need gcc or cygwin to use boost.python by itself.
It works fine with visual studio.

-greg
___
Cplusplus-sig mailing list
Cplusplus-sig@python.org
http://mail.python.org/mailman/listinfo/cplusplus-sig


Re: [C++-sig] new to python; old to C++

2008-11-01 Thread Gustavo Carneiro
2008/11/1 Greg Landrum <[EMAIL PROTECTED]>

> On Sat, Nov 1, 2008 at 4:48 AM, Alan Baljeu <[EMAIL PROTECTED]> wrote:
> >
> > It was a personal question.  Do you specifically do much wrapping stuff
> or not?  I'm
> > trying to gauge your approach compared to how much you do it.  I mean, if
> I had
> > to wrap one C++ function I would of course use the Python API.  If I had
> to grab 2000
> > classes, I would look for something else to help.  What's the breaking
> point?  How
> > quickly does it go for you?
>
> People are obviously going to have different pain points. I use
> straight boost.python to wrap C++ classes and functions, not any of
> the wrapper generators like SWIG or Py++. I find that doing things by
> hand helps me end up with a more "pythonic" wrapper. If I had to deal
> with a large existing class library, I'd probably go a different route
> and use a generator.


My opinion is biased, of course, but I use PyBindGen, usually with the help
of pygccxml for automatic scanning.  I recommend PyBindGen for people that
dislike the kind of C++ template abuse that boost.python does.  Of course I
also recommend anyone starting with pybindgen to be aware of its
limitations, namely lack of support for multiple inheritance and C++
exceptions.


> 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.  The C code generated by SWIG is Python builtin module
providing a bunch of _functions_, not classes and methods.  Then another
module is generated on top, Python code, which "adapts" the functional C
module to make it look more object oriented.


>
>
> an aside: you do not need gcc or cygwin to use boost.python by itself.
> It works fine with visual studio.


pybindgen generated code also compiles fine with visual studio (or at least
the unit test suite does).  You only need (py)gccxml for scanning code, not
for generating.  And generated code does not require any library to
compile.  And you can even skip (py)gccxml if you want API definitions "by
hand", and this way depend only on pybindgen and python for code
generation.  Finally, pybindgen is a small pure python module of which a
copy can easily be included in the project itself ;-)

http://pybindgen.googlecode.com/svn/trunk/apidocs/index.html

-- 
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

Re: [C++-sig] new to python; old to C++

2008-11-01 Thread Paul Melis
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.

Paul
___
Cplusplus-sig mailing list
Cplusplus-sig@python.org
http://mail.python.org/mailman/listinfo/cplusplus-sig


Re: [C++-sig] new to python; old to C++

2008-11-01 Thread Gustavo Carneiro
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

Re: [C++-sig] new to python; old to C++

2008-11-01 Thread Alan Baljeu
On Sat, Nov 1, 2008 at 3:32 AM, Alan Baljeu <[EMAIL PROTECTED]> wrote:
>> My first impression of Py++ is that it generates stuff for Boost.Python to 
>> use to connect 
>>Python to C++.  To get it going I also need to introduce GCC, and probably 
>>Cygwin.  That seems like a lot of layers.  Does this not make for a 
>> complicated system, with a lot to learn?

> Where did you read this. Py++ has dependency on GCC-XML, not on GCC,
> neither on cygwin.

http://www.language-binding.net/pyplusplus/pyplusplus.html says:
"""

Py++ does not reinvent the wheel. It uses GCC C++ compiler to parse C++
source files. To be more precise, the tool chain looks like this:
1. source code is passed to GCC-XML
2. GCC-XML passes it to GCC C++ compiler
3. GCC-XML generates an XML description of a C++ program from GCC's 
internal
representation.
4. Py++ uses pygccxml package to read GCC-XML generated file."""


  __
Yahoo! Canada Toolbar: Search from anywhere on the web, and bookmark your 
favourite sites. Download it now at
http://ca.toolbar.yahoo.com.
___
Cplusplus-sig mailing list
Cplusplus-sig@python.org
http://mail.python.org/mailman/listinfo/cplusplus-sig


Re: [C++-sig] new to python; old to C++

2008-11-01 Thread Alan Baljeu
2008/11/1 Greg Landrum <[EMAIL PROTECTED]>
<<<
My opinion is biased, of course, but I use PyBindGen, usually with the help of 
pygccxml for automatic scanning.  I recommend PyBindGen for people that dislike 
the kind of C++ template abuse that boost.python does.  Of course I also 
recommend anyone starting with pybindgen to be aware of its limitations, namely 
lack of support for multiple inheritance and C++ exceptions. 
>>>

This is what attracts me to PyBindGen.  I dislike "template abuse", and my C++ 
doesn't use multiple inheritance or exceptions.  Any other limitations I should 
know?

<<<
pybindgen generated code also compiles fine with visual studio (or at least the 
unit test suite does).  You only need (py)gccxml for scanning code, not for 
generating.  And generated code does not require any library to compile.  And 
you can even skip (py)gccxml if you want API definitions "by hand", and this 
way depend only on pybindgen and python for code generation.  Finally, 
pybindgen is a small pure python module of which a copy can easily be included 
in the project itself ;-)

http://pybindgen.googlecode.com/svn/trunk/apidocs/index.html
>>>
So you use gccxml as well. Does it make a big diff?



  __
Be smarter than spam. See how smart SpamGuard is at giving junk email the boot 
with the All-new Yahoo! Mail.  Click on Options in Mail and switch to New Mail 
today or register for free at http://mail.yahoo.ca
___
Cplusplus-sig mailing list
Cplusplus-sig@python.org
http://mail.python.org/mailman/listinfo/cplusplus-sig


Re: [C++-sig] new to python; old to C++

2008-11-01 Thread Gustavo Carneiro
2008/11/1 Alan Baljeu <[EMAIL PROTECTED]>

> 2008/11/1 Greg Landrum <[EMAIL PROTECTED]>
> <<<
> My opinion is biased, of course, but I use PyBindGen, usually with the help
> of pygccxml for automatic scanning.  I recommend PyBindGen for people that
> dislike the kind of C++ template abuse that boost.python does.  Of course I
> also recommend anyone starting with pybindgen to be aware of its
> limitations, namely lack of support for multiple inheritance and C++
> exceptions.
> >>>
>
> This is what attracts me to PyBindGen.  I dislike "template abuse", and my
> C++ doesn't use multiple inheritance or exceptions.  Any other limitations I
> should know?


See http://code.google.com/p/pybindgen/wiki/Features
And also the open bug reports: https://bugs.launchpad.net/pybindgen/+bugs

But even I don't know all the pybindgen limitations :P


>
>
> <<<
> pybindgen generated code also compiles fine with visual studio (or at least
> the unit test suite does).  You only need (py)gccxml for scanning code, not
> for generating.  And generated code does not require any library to compile.
>  And you can even skip (py)gccxml if you want API definitions "by hand", and
> this way depend only on pybindgen and python for code generation.  Finally,
> pybindgen is a small pure python module of which a copy can easily be
> included in the project itself ;-)
>
> http://pybindgen.googlecode.com/svn/trunk/apidocs/index.html
> >>>
> So you use gccxml as well. Does it make a big diff?


pybindgen has _one_ layer that uses gccxml for scanning, but it is optional;
use it if you like, or don't.

I think gccxml scanning is important for large APIs which have a tendency to
change over time.  If you have a small and mostly static API then it should
be OK to just manually write the API definition by hand (in a Python-based
IDL).  Otherwise it becomes tedious to do it by hand.

-- 
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