brandtbucher · GitHub

Bug report

Example:

>>> c = """ 
... X = None
... 
... def f():
...     return X
... 
... # Specialize the global load X:
... f()
... f()
... 
... # Replace it with a lazy placeholder:
... lazy import X
... 
... # Lazy import not resolved, cached lookup used instead:
... print(f())
... """
>>> exec(c, {})
<lazy_import 'X'>

We need to ensure that a watcher is installed on the global (and probably builtin?) namespaces when specializing global loads, just in case they aren't actual module __dicts__. I'll open a PR soon.

Linked PRs

Read the original on github.com ↗