Mark Shannon <m...@hotpy.org> added the comment:
Yes. Simpler is good. I think it will also be better for performance: In general, we don't know what X is in `from Y import X`. It could be a module or anything else. However, if we are accessing an attribute it is quite likely to be a module or class. For `X` defined by `from Y import X`, `X` is likely to be a module, class, function, or some sort of constant like a string, int or Enum. If it is a string, int or function then it is rare to call a method on it, so we can ignore that case. Calling methods on an Enum constant is probably not very common either (I'm guessing here) For a module, `LOAD_ATTR; CALL_FUNCTION` is clearly better than `LOAD_METHOD; CALL_METHOD`. For a class, specializing `LOAD_ATTR` is no more complex than `LOAD_METHOD`, probably simpler. So, for a class `LOAD_ATTR; CALL_FUNCTION` is no worse than `LOAD_METHOD; CALL_METHOD`, and might be better. Overall, it looks like `X.foo()` when `X` is defiend by `from Y import X` is best as `LOAD_ATTR; CALL_FUNCTION` not `LOAD_METHOD; CALL_METHOD`. ---------- _______________________________________ Python tracker <rep...@bugs.python.org> <https://bugs.python.org/issue44313> _______________________________________ _______________________________________________ Python-bugs-list mailing list Unsubscribe: https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com