[Python-3000] Binding builtin function to class
Haoyu Bai
divinekid at gmail.com
Mon Apr 28 13:14:00 CEST 2008
Richard Boulton wrote:
> Yes, this is what Haoyu was talking about - I suspect he meant "doesn't
> work" rather than "cannot work", and that's the reason it doesn't work
> (both in 2.x and 3.0).
Thanks Richard for helping me to explain.
> I'll ask a direct question: what is the recommended replacement for
> new.instancemethod? In particular, what would be the recommended
> replacement for the following code snippet?
>
> class TestBase(object):
> """Proxy of C++ TestBase class"""
> #some unrelated code omitted
> pass
> #_test.TestBase_test is the C function in _test DLL module
> TestBase.test = new.instancemethod(_test.TestBase_test,None,TestBase)
>
>
> A secondary question is whether new.instancemethod was ever the right
> way for SWIG to be working: the person who originally wrote the python
> backend for SWIG isn't around any more, as far as I know, so we don't
> have knowledge of the reason that the code was written this way.
>
Yes, these are the very problems I encountered. I think the using of
"new.instancemethod" is for speed, because in SWIG's command line, the
"-fastproxy" option enabled it:
-fastproxy - Use fast proxy mechanism for member methods
So what we expect is to find a way doing this in Python 3, as fast as
the "new.instancemethod".
Best regards,
Haoyu Bai
4/28/2008
More information about the Python-3000
mailing list