Message233815
I'm suggesting we change this part of the bytecode emitted for "import x.y.z as bar":
6 IMPORT_NAME 0 (x.y.z)
9 LOAD_ATTR 1 (y)
12 LOAD_ATTR 2 (z)
15 STORE_NAME 3 (bar)
to instead emit:
6 IMPORT_NAME 0 (x.y)
9 IMPORT_FROM 1 (z)
12 STORE_NAME 2 (bar)
15 POP_TOP
The degenerate case of "import x as y" would be unchanged, only cases which currently emit LOAD_ATTR instructions would be modified.
I haven't looked at the practical details yet, but the key would be to use IMPORT_FROM to do the name resolution, rather than LOAD_ATTR, thus enabling the fallback to sys.modules for the eager lookup. |
|
Date |
User |
Action |
Args |
2015-01-10 11:06:23 | ncoghlan | set | recipients:
+ ncoghlan, brett.cannon, ezio.melotti, eric.snow, franck |
2015-01-10 11:06:23 | ncoghlan | set | messageid: <1420887983.7.0.14192013661.issue23203@psf.upfronthosting.co.za> |
2015-01-10 11:06:23 | ncoghlan | link | issue23203 messages |
2015-01-10 11:06:23 | ncoghlan | create | |
|