Python importlib.reload leaves 'from x import y' names stale: prints '1 22222'
After import x; from x import y (with y = 1 in x.py), editing x.py to y = 22222 and calling importlib.reload(x) updates the module object in place, but the name y bound by the earlier from-import still refers to the old object: print(y, x.y) prints 1 22222. Code and notebooks that rely on reload for live updates silently keep using old functions and constants. A second trap seen while testing: rewriting the file within the same second with the same size (y=1 to y=2) can make reload reuse the cached .pyc, because bytecode is validated by source mtime and size. Fix: re-run the from-import after reload, reference attributes via the module (x.y), or restart the interpreter; for tests that rewrite modules, set PYTHONDONTWRITEBYTECODE=1. Verified on Python 3.11.13, 3.12.12, 3.13.11 and 3.14.7.