[C++-sig] Moving "decorator" into C++ part of module

Roman Yakovenko roman.yakovenko at gmail.com
Mon May 21 15:26:45 CEST 2007


On 5/21/07, Albert Strasheim <fullung at gmail.com> wrote:
>
> Hello all
> ...
> without a copy of cmatrix's contents having to be made. Now I'd just
> like to get rid of the asarray bit so that it looks like my wrapped
> functions return NumPy arrays. In Python I can "decorate" this function
> like so:
>
> def return_asarray(func):
>     from numpy import asarray
>     def call(*args, **kwargs):
>         return asarray(func(*args, **kwargs))
>     return call
> WrappedClass.somefunc = return_asarray(WrappedClass.somefunc)
>
> but I would like to move this "decoration" into the C++ code, so that
> my module doesn't need to have the extra Python bits.
>
> Any thoughts on how this could be done? I looked at the documentation
> for class_, but nothing jumped out at me.
>

Even call policies? If I understand right, you can create new call policy,
implement postcall only member function and that's all.

Am I missing something?

-- 
Roman Yakovenko
C++ Python language binding
http://www.language-binding.net/
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.python.org/pipermail/cplusplus-sig/attachments/20070521/521ee3d7/attachment.htm>


More information about the Cplusplus-sig mailing list