I've been using different ad-hoc variations on this, especially in numpy / pandas / data science-y applications. For example let's say I've done some intensive processing that outputs a numpy array and there's probably no need to redo that part of the code. While debugging I want to rerun the script but avoid that processing. So I dump that array to a file and then wrap that part of the code in some form of "if the dumped file exists and it's ok, load it, else run the processing again, and save that output". The idea is to make the script behave a bit like a jupyter notebook.
I know it's pretty simple to write something like that most of the time, I was just wondering if there's an established pattern for how people do it so that I look like I know what I'm doing. Try-block? Decorators? Context managers? Commenting and uncommenting the same 5 lines of code like a psychopath?
Thanks for any help.