[Python-Dev] About 'superobject' and descriptors (original) (raw)

hakril lse hakril at lse.epita.fr
Wed Oct 23 19:29:03 CEST 2013


Hi,

I have a question about a choice of implementation concerning 'superobject' with the descriptors.

When a 'superobject' looks for a given attribute, it runs through the mro of the object. If it finds a descriptor, the 'superobject' calls the get method with 'starttype = su->obj_type' as third argument (in typeobject.c: super_getattro).

So, the 'type' argument of get does not give more information about the 'real calling type' in this case. It seems that this is just a redundant information of inst.class.

For example:

# A.descr is a descriptor
# B inherit from A
# C inherit from B

    c = C()
    c.descr
    super(C, c).descr
    super(B, c).descr

In these 3 cases the get method is called with the same arguments that are : get(descr, c, C).

If this behavior is really expected: Could you explain why ? because it means that I am missing something obvious. Because, at first sight, the 'type' argument seems to be the perfect place to get the type of the 'real calling class'.

Thank you,

-- hakril



More information about the Python-Dev mailing list