C code代表Python的财产功能? [英] C Code for Python's property function?

查看:102
本文介绍了C code代表Python的财产功能?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我来真的很好奇如何 Python的跨preTER使一个属性 X 出的方法 X X =属性(X)。如果我能看看在 C code,我就感觉好多了。

I am really curious as to how Python's interpreter makes an attribute x out of a method x through x=property(x). If I could take a look at the C code, I would feel much better.

推荐答案

该类型在的 descrobject.c 文件

The type is defined in the descrobject.c file.

您可以通过先寻找 <$ C $函数名找到Python类型这样的C> bltinmodule.c ;在这种情况下,以下行定义了属性()功能:

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

SETBUILTIN("property",              &PyProperty_Type);

然后用grep在对象的 PyProperty_Type 定义子目录中。

then grep for the PyProperty_Type definition in the Objects subdirectory.

这篇关于C code代表Python的财产功能?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆