Jesus Cea wrote:
> Amaury Forgeot d'Arc wrote:
> |> My doubt now is how do write a *clever* "getattr" routine without
> |> "Py_FindMethod".
> |
> | Well, I'd write a "tp_getattro" member function,
> | which would do its "clever" things before it falls back to
> | PyObject_GenericGetAttr to get the usual behaviour.
>
> Now I'm confused about difference between "tp_getattro" and
> "tp_getattr", and when to use them.

They are identical, except that tp_getattr takes a char*, when
tp_getattro wants a PyObject*.
(see the code in Object/object.c::PyObject_GetAttr())

> I guess that "tp_methods" and "tp_members" are faster, but only usable
> when the data is "static" and available, while "tp_getattr" and friends
> are used when you need to execute some code in the lookup.

Yes. Fortunately, it's not often the case.

> But I read
> somewhere that "tp_getattr" was deprecated :-? ...

Deprecated in favor of tp_getattro I presume.

-- 
Amaury Forgeot d'Arc
_______________________________________________
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