On Sun, 18 Apr 2021, 1:59 am Jelle Zijlstra, <[email protected]> wrote:
> El sáb, 17 abr 2021 a las 8:30, Nick Coghlan (<[email protected]>) > escribió:. > >> >> Metaclass __prepare__ methods can inject names into the class namespace >> that the compiler doesn't know about, so yeah, it unfortunately has to be >> conservative and use LOAD_NAME in class level code. >> >> But of course, most metaclasses don't. I wonder if there are cases where > the compiler can statically figure out that there are no metaclass > shenanigans going on, and emit LOAD_GLOBAL anyway. It seems safe at least > when the class has no base classes and no metaclass=. > Aye, that particular case is one the symtable pass could at least theoretically identify. As soon as there is a name to resolve in the class header, though, it's no longer safe for the compiler to make assumptions :( Cheers, Nick. > >>
_______________________________________________ Python-Dev mailing list -- [email protected] To unsubscribe send an email to [email protected] https://mail.python.org/mailman3/lists/python-dev.python.org/ Message archived at https://mail.python.org/archives/list/[email protected]/message/NDYKJTWUN4HT2BPNJVBUKYVD6HOTIBMY/ Code of Conduct: http://python.org/psf/codeofconduct/
