> Also, I have to think this would be appreciably slower than the current
> mechanism, having to run through this ChainMap cascade for (almost) *every*
> attribute lookup?
>

If I remember correctly, ChainMap is pretty fast. I doubt it would be
appreciably slower, though it would undoubtedly be some amount slower in at
least some cases.

For modules: no, the second level mapping would only be consulted in cases
that the name wasn't found in the first level. There would be a very minor
speed hit due to the ChainMap overhead, probably not anything anyone would
worry about. Consulting two dictionaries instead of one is a very very very
minor penalty.

For classes, it's worse: the successive alias mappings would be consulted
at each level of the MRO in cases a name wasn't found in the normal
attribute dict for the first member of the MRO, which is certainly going to
be *much* of the time. How bad a hit is this? It would depend on how long
the MRO is; it would double the number of dict lookups for any given
attribute lookup. Is that an appreciable slow down? I don't know. I kind of
doubt it though.
_______________________________________________
Python-ideas mailing list -- python-ideas@python.org
To unsubscribe send an email to python-ideas-le...@python.org
https://mail.python.org/mailman3/lists/python-ideas.python.org/
Message archived at 
https://mail.python.org/archives/list/python-ideas@python.org/message/G757USKVK63ROG7BQLCKPVBRMX76HK4J/
Code of Conduct: http://python.org/psf/codeofconduct/

Reply via email to