[Python-ideas] LOAD_NAME/LOAD_GLOBAL should be use getattr()
Serhiy Storchaka
storchaka at gmail.com
Thu Sep 14 10:08:13 EDT 2017
More information about the Python-ideas mailing list
Thu Sep 14 10:08:13 EDT 2017
- Previous message (by thread): [Python-ideas] LOAD_NAME/LOAD_GLOBAL should be use getattr()
- Next message (by thread): [Python-ideas] LOAD_NAME/LOAD_GLOBAL should be use getattr()
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]
13.09.17 23:07, Lucas Wiman пише: > On Wed, Sep 13, 2017 at 11:55 AM, Serhiy Storchaka > <storchaka at gmail.com > <mailto:storchaka at gmail.com>> wrote: > > [...] Calling __getattr__() will slow down the access to builtins. > And there is a recursion problem if module's __getattr__() uses > builtins. > > > The first point is totally valid, but the recursion problem doesn't > seem like a strong argument. There are already lots of recursion > problems when defining custom __getattr__ or __getattribute__ methods, > but on balance they're a very useful part of the language. In normal classes we have the recursion problem in __getattr__() only with accessing instance attributes. Builtins (like isinstance, getattr, AttributeError) can be used without problems. In module's __getattr__() all this is a problem. Module attribute access can be implicit. For example comparing a string with a byte object in __getattr__() can trigger the lookup of __warningregistry__ and the infinity recursion.
- Previous message (by thread): [Python-ideas] LOAD_NAME/LOAD_GLOBAL should be use getattr()
- Next message (by thread): [Python-ideas] LOAD_NAME/LOAD_GLOBAL should be use getattr()
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]
More information about the Python-ideas mailing list