On 2013-10-21, Marcin Szamotulski wrote:
> So the process (with some simplifications) goes like this:
>
> 1. get metaclass: meta
> 2. call meta.__prepare__ to get namespace (class __dict__)
> 3. evaluate the class body in the namespace
> 4. call meta with arguemnts: name, bases, na
You can inspect the process in this way:
>>> c = 'class A: pass'
>>> code = compile(c, '', 'exec')
>>> from dis import dis
>>> dis(code)
1 0 LOAD_BUILD_CLASS
1 LOAD_CONST 0 (", line 1>)
4 LOAD_CONST 1 ('A')
7 MAKE_FUN
Hi all,
I'm trying to wrap my head around how classes are constructed at the
interpreter level (as a side effect of digging into metaclasses) and
I'm hoping to have my investigation either validated or ridiculed ;)
The pipeline that I've figured through some gdb debugging (starting at
type_call):