Terry Reedy wrote:
| But in the case of builtin function, it can't work.

What is it that 'cannot work'? My guess is that you are talking about the fact that instances do not get bound as an argument to the first parameter of a builtin.

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

If *extension* function show a difference, perhaps SWIG needs revision for 3.x.

SWIG does need an update for 3.0: this is precisely what Haoyu is working on! :)

I don't think this particular aspect of extension functions has changed in 3.0, as you say, but the problem Haoyu is trying to solve is working out what to replace usage of new.instancemethod with, as described in the code snippets at the end of his email. SWIG currently generates code for python 2.x which makes heavy use of new.instancemethod, and since "new" is deprecated in 3.0, we need to find a replacement.

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.

[Builtin callables are also different in respect to parameter naming and binding args by keyword. Perhaps to reduce confusion, they should not be named 'functions' in the manuals.]

That might be helpful for beginners, yes.

--
Richard
_______________________________________________
Python-3000 mailing list
Python-3000@python.org
http://mail.python.org/mailman/listinfo/python-3000
Unsubscribe: 
http://mail.python.org/mailman/options/python-3000/archive%40mail-archive.com

Reply via email to