开发者

When are the first Python objects 'object' and 'type' instances created?

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 开发者_StackOverflow中文版then 'ready for use' when the interpreter is first started. Am I correct ?


For all intents and purposes, the object and type 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.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜