第一个 Python 对象“object”何时出现?并“输入”实例已创建?
阅读: http://www.python.org/download/releases/2.2 /descrintro/#metaclasses
执行类语句,然后将名称、基础和属性字典传递给元类对象。由于“type”是一个实例 - isinstance(type, type),它已经是一个对象了。第一个实例何时/如何创建?
我的猜测是,第一个实例是由核心 C 代码创建的,然后在解释器首次启动时“准备使用”。我说得对吗?
Reading: http://www.python.org/download/releases/2.2/descrintro/#metaclasses
A class statement is executed and then the name, bases, and attributes dict are passed to a metaclass object. Since 'type' is an instance - isinstance(type, type), it is an object already. When/how is the very first instance created ?
My guess is that the first instance was created by the core C code and is then 'ready for use' when the interpreter is first started. Am I correct ?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
出于所有意图和目的,
object
和type
对象是在解释器启动期间创建的,是的。实际上,在CPython中,两个对象的一部分是静态分配的,一部分是在Python启动期间分配的。For all intents and purposes, the
object
andtype
objects are created during interpreter startup, yes. In practice, in CPython, parts of the two objects are allocated statically, and parts are allocated during Python startup.