C Code for Python property function?

I'm really curious how how the Python interpreter makes the x attribute outside the x method via x=property(x) . If I could take a look at the C code, I would feel much better.

+4
source share
1 answer

The type is defined in the descrobject.c file.

You can find Python types like these, first look for the function name in bltinmodule.c ; in this case, the following line defines the property() function:

 SETBUILTIN("property", &PyProperty_Type); 

then grep to define PyProperty_Type in the Objects subdirectory.

+9
source

Source: https://habr.com/ru/post/1479801/


All Articles