[Python-ideas] LOAD_NAME/LOAD_GLOBAL should be use getattr()

Steven D'Aprano steve at pearwood.info
Thu Sep 14 09:07:16 EDT 2017


On Wed, Sep 13, 2017 at 12:24:31PM +0900, INADA Naoki wrote:
> I'm worring about performance much.
> 
> Dict has ma_version from Python 3.6 to be used for future optimization
> including global caching.
> Adding more abstraction layer may make it difficult.

Can we make it opt-in, by replacing the module __dict__ when and only if 
needed? Perhaps we could replace it on the fly with a dict subclass that 
defines __missing__? That's virtually the same as __getattr__.

Then modules which haven't replaced their __dict__ would not see any 
slow down at all.

Does any of this make sense, or am I talking nonsense on stilts?




-- 
Steve


More information about the Python-ideas mailing list