[Python-3000] methods and members (original) (raw)
Guido van Rossum guido at python.org
Sun Mar 11 01:21:09 CET 2007
- Previous message: [Python-3000] __methods__ and __members__
- Next message: [Python-3000] __methods__ and __members__
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]
On 3/9/07, Georg Brandl <g.brandl at gmx.net> wrote:
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 imself 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 tpgetattr 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 ;)
I'm sure we can drop al and fl. I expect we can drop sunaudiodev too, and I seem to recall there's no-one to maintain the RISCOS code; but for sunaudiodev and RISCOS it would be better to ask on python-dev.
Then, we have cases like pyexpat.c, where attributes are dynamically read in getattr. This could also be done with tpgetset, but it may be quite a bit slower. But this is only one type, and it could get a custom dir function.
I recommend doing the simplest thing that could possibly work. If it's too slow someone will speed it up.
There are also quite a few modules whose types have a getattr which only calls PyFindMethod. This can easily be replaced with a tpmethods slot entry.
Yeah, they didn't get changed earlier because there was no incentive. :-)
Another oddity is that PyFindMethod checks if doc is requested, and returns it. Is that still necessary?
I'm pretty sure the new code in typeobject.py handles that too -- otherwise how would doc for modern types work?
-- --Guido van Rossum (home page: http://www.python.org/~guido/)
- Previous message: [Python-3000] __methods__ and __members__
- Next message: [Python-3000] __methods__ and __members__
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]