This issue tracker has been migrated to GitHub, and is currently read-only.
For more information, see the GitHub FAQs in the Python's Developer Guide.

Author methane
Recipients methane, pablogsal, pfalcon, ppperry, terry.reedy, vstinner
Date 2020-01-17.11:59:42
SpamBayes Score -1.0
Marked as misclassified Yes
Message-id <>
> 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:42methanesetrecipients: + methane, terry.reedy, pfalcon, vstinner, ppperry, pablogsal
2020-01-17 11:59:42methanesetmessageid: <>
2020-01-17 11:59:42methanelinkissue32615 messages
2020-01-17 11:59:42methanecreate