Message360172
> Ironically, to let people prototype better, more efficient ways to deal with namespace access, it should be possible to override an object used as a namespace.
You can benchmark your prototype namespace object by regular Python code:
d["name"] # LOAD_GLOBAL
d["name"] = 1 # STORE_GLOBAL
So I don't think no overriding blocks prototyping.
On the other hand, allowing overriding makes future optimizations difficult. For example:
```
>>> import dis
>>> def counter():
... global _cnt
... _cnt += 1
... return _cnt
...
>>> dis.dis(counter)
3 0 LOAD_GLOBAL 0 (_cnt)
2 LOAD_CONST 1 (1)
4 INPLACE_ADD
6 STORE_GLOBAL 0 (_cnt)
4 8 LOAD_GLOBAL 0 (_cnt)
10 RETURN_VALUE
```
We may be possible to replace bytecode from `STORE_GLOBAL _cnt; LOAD_GLOBAL _cnt` into `DUP_TOP; STORE_GLOBAL _cnt`.
If we guarantee namespace overriding, it's very easy to break the guarantee while such optimization. |
|
Date |
User |
Action |
Args |
2020-01-17 11:59:42 | methane | set | recipients:
+ methane, terry.reedy, pfalcon, vstinner, ppperry, pablogsal |
2020-01-17 11:59:42 | methane | set | messageid: <1579262382.73.0.389151198241.issue32615@roundup.psfhosted.org> |
2020-01-17 11:59:42 | methane | link | issue32615 messages |
2020-01-17 11:59:42 | methane | create | |
|