Boost python and boost signal

classic Classic list List threaded Threaded
5 messages Options
Reply | Threaded
Open this post in threaded view
|

Boost python and boost signal

Jay Riley
I was wondering if it's possible to hook python functions as slots into boost::signal or boost::signal2 signals? I found an old thread that said it wasn't directly possible, but it was from 2004.

_______________________________________________
Cplusplus-sig mailing list
[hidden email]
http://mail.python.org/mailman/listinfo/cplusplus-sig
Reply | Threaded
Open this post in threaded view
|

Re: Boost python and boost signal

Stefan Seefeld-2
On 11/21/2011 09:08 AM, Jay Riley wrote:
> I was wondering if it's possible to hook python functions as slots
> into boost::signal or boost::signal2 signals? I found an old thread
> that said it wasn't directly possible, but it was from 2004.

Given that it's possible to wrap Python functions in ordinary C++
functions / function objects, I don't see why it shouldn't be possible
to use Python functions wherever you'd be able to use C++ functions.
Just be careful with proper Python runtime initialization and thread safety.

    Stefan

--

      ...ich hab' noch einen Koffer in Berlin...

_______________________________________________
Cplusplus-sig mailing list
[hidden email]
http://mail.python.org/mailman/listinfo/cplusplus-sig
Reply | Threaded
Open this post in threaded view
|

Re: Boost python and boost signal

Niall Douglas
In reply to this post by Jay Riley
On 21 Nov 2011 at 9:08, Jay Riley wrote:

> I was wondering if it's possible to hook python functions as slots into
> boost::signal or boost::signal2 signals? I found an old thread that said
> it wasn't directly possible, but it was from 2004.      

Integrating this properly - or rather an enhanced version of it - was
one of the ideas mooted for the next version of Boost.Python some
months ago. Some clever metaprogramming can even allow python to work
with arbitrary function pointers for callbacks :) However I don't
think it's on the cards for what Jim is currently planning.

Niall

--
Technology & Consulting Services - ned Productions Limited.
http://www.nedproductions.biz/. VAT reg: IE 9708311Q. Company no:
472909.



_______________________________________________
Cplusplus-sig mailing list
[hidden email]
http://mail.python.org/mailman/listinfo/cplusplus-sig
Reply | Threaded
Open this post in threaded view
|

Re: Boost python and boost signal

Stefan Seefeld-2
On 11/21/2011 01:06 PM, Niall Douglas wrote:

> On 21 Nov 2011 at 9:08, Jay Riley wrote:
>
>> I was wondering if it's possible to hook python functions as slots into
>> boost::signal or boost::signal2 signals? I found an old thread that said
>> it wasn't directly possible, but it was from 2004.      
> Integrating this properly - or rather an enhanced version of it - was
> one of the ideas mooted for the next version of Boost.Python some
> months ago. Some clever metaprogramming can even allow python to work
> with arbitrary function pointers for callbacks :) However I don't
> think it's on the cards for what Jim is currently planning.

Out of curiosity: what are the issues preventing this from "Just Work" ?

    Stefan


--

      ...ich hab' noch einen Koffer in Berlin...

_______________________________________________
Cplusplus-sig mailing list
[hidden email]
http://mail.python.org/mailman/listinfo/cplusplus-sig
Reply | Threaded
Open this post in threaded view
|

Re: Boost python and boost signal

Niall Douglas
On 21 Nov 2011 at 13:16, Stefan Seefeld wrote:

> >> I was wondering if it's possible to hook python functions as slots into
> >> boost::signal or boost::signal2 signals? I found an old thread that said
> >> it wasn't directly possible, but it was from 2004.      
> > Integrating this properly - or rather an enhanced version of it - was
> > one of the ideas mooted for the next version of Boost.Python some
> > months ago. Some clever metaprogramming can even allow python to work
> > with arbitrary function pointers for callbacks :) However I don't
> > think it's on the cards for what Jim is currently planning.
>
> Out of curiosity: what are the issues preventing this from "Just Work" ?

Well, as a minimum, my code would need to be recoded to use Boost
rather than my own metaprogramming library. It would then need to
pass peer review etc.

However, as a wider issue, deep thought would need to be put into how
exactly BPL traverses between "python" and "not python" and a
strictly defined API decided upon. Right now, this boundary isn't
tightly defined e.g. when you iterate through a wrapped container,
exactly how far outside python is one venturing etc. Defining it
tightly and not accidentally introducing problems for yourself later
would be real tough though. Hence the deep thought being necessary.

Niall

--
Technology & Consulting Services - ned Productions Limited.
http://www.nedproductions.biz/. VAT reg: IE 9708311Q. Company no:
472909.



_______________________________________________
Cplusplus-sig mailing list
[hidden email]
http://mail.python.org/mailman/listinfo/cplusplus-sig