Raymond Hettinger added the comment:
> Did you mean importlib.reload() instead of sys.reload()?
Yes.
> And technically it would *if* you're okay with the other
> side-effects of reloading,
If you want to go forward with this, go for it. I would like to be able to
explain to another person
Brett Cannon added the comment:
Did you mean importlib.reload() instead of sys.reload()?
And technically it would *if* you're okay with the other side-effects of
reloading, e.g. making sure no one has a reference to any objects from the
module's namespace which won't change in-place (e.g. if
Raymond Hettinger added the comment:
Quick question, would the existing sys.reload() logic suffice?
-- mymodule.py --
cache = {} # On reload, this would clear the cache
def f(x):
if x in cache:
return cache[x]
y = x**2
cache[x] = y
return y
-
Raymond Hettinger added the comment:
[Brett]
> To me, the priority is clearing caches on a per-module basici
> and having a clear-all mechanism can be beneficial, not the
> other way around.
That makes more sense.
I'm changing the title to match the actual feature request and intent:
"Add a