4 ms·
> do any linters complain about input modification or out-of-scope references? I know Instagram was experimenting with something similar to this a couple years
by gen220 5y ago
> do any linters complain about input modification or out-of-scope references?
I know Instagram was experimenting with something similar to this a couple years ago (“Python strict modules”).
It might be possible to implement function purity with a decorator. (Kind of like declaring something “safe” in Rust).
Definitely agree that Python is becoming more amenable to functional style programming over time. And it’s great!
- ianandrich 5y ago> It might be possible to implement function purity with a decorator. (Kind of like declaring something “safe” in Rust). Two parts to this. 1: Does it mutate variables. 2. Does the code have side effects. 1: def no_mut(func): @functools.wraps def new_func(args, *kwargs): new_args = tuple(copy.deepcopy(arg) for arg in args) new_kwargs = {k, copy.deepcopy(v) for k, v in *kwargs return func(new_args, *new_kwargs) return new_func For the second point, gevent seemed to have a trick to identify side effecting code.