El sáb, 17 abr 2021 a las 8:30, Nick Coghlan (<ncogh...@gmail.com>) escribió:
> > > On Fri, 16 Apr 2021, 3:14 pm Larry Hastings, <la...@hastings.org> wrote: > >> >> Anyway I assume it wasn't "fixable". The compiler would presumably >> already prefer to generate LOAD_GLOBAL vs LOAD_NAME, because LOAD_GLOBAL >> would be cheaper every time for a global or builtin. The fact that it >> already doesn't do so implies that it can't. >> > > 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=. > Cheers, > Nick. > >> >> _______________________________________________ > Python-Dev mailing list -- python-dev@python.org > To unsubscribe send an email to python-dev-le...@python.org > https://mail.python.org/mailman3/lists/python-dev.python.org/ > Message archived at > https://mail.python.org/archives/list/python-dev@python.org/message/IZJYDHWJNMMMICUE32M3O7DGMSMVIOQ3/ > Code of Conduct: http://python.org/psf/codeofconduct/ >
_______________________________________________ Python-Dev mailing list -- python-dev@python.org To unsubscribe send an email to python-dev-le...@python.org https://mail.python.org/mailman3/lists/python-dev.python.org/ Message archived at https://mail.python.org/archives/list/python-dev@python.org/message/W4LYALS5RMLTGIU5PE5YMF4L3MWL2HXY/ Code of Conduct: http://python.org/psf/codeofconduct/