[Python-3000] __methods__ and __members__
Georg Brandl
g.brandl at gmx.net
Sat Mar 10 08:55:28 CET 2007
Guido van Rossum schrieb:
> I don't recall ripping them out, but it's worth trying to do that --
> they really shouldn't be needed for modern extensionmodules (2.2+).
>
> On 3/7/07, Georg Brandl <g.brandl at gmx.net> wrote:
>> While reviewing the patch for __dir__() (which I'll apply then, since it was
>> generally agreed upon at least for Py3k), I came about this:
>>
>> /* Merge in __members__ and __methods__ (if any).
>> XXX Would like this to go away someday; for now, it's
>> XXX needed to get at im_self etc of method objects. */
>>
>> What is the status of __methods__ and __members__? Is this (and the docs)
>> the only trace that's left of it?
Okay, I looked into it.
The old attribute semantics of offering a custom tp_getattr
which dispatches to methods and members is mainly used in very old
and platform-specific extension modules like RISCOS/*,
Modules/{al,fl,sunaudiodev}module. If we decide to drop some of them,
it would be nice to do it before working on them ;)
Then, we have cases like pyexpat.c, where attributes are dynamically
read in getattr. This could also be done with tp_getset, but it may
be quite a bit slower. But this is only one type, and it could get
a custom __dir__ function.
There are also quite a few modules whose types have a getattr which
only calls Py_FindMethod. This can easily be replaced with a tp_methods
slot entry.
Another oddity is that Py_FindMethod checks if __doc__ is requested, and
returns it. Is that still necessary?
Georg
More information about the Python-3000
mailing list