[C++-sig] optimizing away calls to the python runtime -- was [detecting if a function is written in python or C++]

François Duranleau duranlef at iro.umontreal.ca
Fri Jan 27 18:24:03 CET 2006


On Fri, 27 Jan 2006, Mathieu Lacage wrote:

> > On Wed, 2006-01-18 at 15:09 -0500, François Duranleau wrote:

> > template < typename Function ,
> >             typename Tag >
> > struct function_wrapper_callback
> >      : Callback1
> > {
> >      static Function func ;
> > 
> >      void operator () ( int a )
> >      {
> >          func( a ) ;
> >      }
> > } ;
> > 
> > template < typename Function ,
> >             typename Tag >
> > Function function_wrapper< Function , Tag >::func = Function() ;
>
> you meant function_wrapper_callback here, I assume.

Oops, yes, of course!

[...]
> > And in the module section, taking your example of function 
> > 'real_function', you could export it like this:
> > 
> > // declare the tag ouside of BOOST_PYTHON_MODULE(...)
> > struct real_function_tag ;
> > 
> > export_function_callback< real_function_tag >( & real_function ,
> >                                                "real_function_callback" );
> 
> Am I right in assuming that your "tag" is here to deal with multiple
> functions having the same signature ?

Right!

-- 
François Duranleau
LIGUM, Université de Montréal

"I can't do the subtraction. 16 minus 7. You borrow 10 from the tens
  column... and take away 7. And then add 6... When do you return the
  borrowed 10?"
                                                           - Jiyu Nanohanu,
            in _Jubei-Chan, The Ninja Girl, Secret of the Lovely Eye Patch_


More information about the Cplusplus-sig mailing list