I have the following problem.
My program will heavily work with plugins, which will perform computationally demanding tasks. But in different runs of the program the required operations (performed by plugins) may be the same. In order to speed things up (among other reasons), I would like to detect that the user gave the program the same plugin. Plugin is just a callable in my case.
The question is - how can I detect it?
Of course, code equivalence is absolute necessity for this kind of check, as was pointed out in (*). But obviously, it is not sufficient (**).
Because I will pass the arguments by their names (i.e. by dict unpacking), it surely needs to be checked that the the same arguments play the same role in the function.
Simalarly, something clearly must be forbidden. For example to load some data from a file and produce the output out of them (then any meaningful check is undoable).
Ideally, I would like to achieve similar mechanism that works well in functional languages, that is the output of a function is fully determined by values its arguments. Then if the function recieves the same set of arguments, its output can be just loaded (in one run of the program, though). Such mechanism relies of the fact that these functions are stateless.
To state my question more clearly - what kinds of restrictions (not necessarily checkable - they can be only documented) do I need to put on functions that come to me to be able to check that two of them are the same? (For example use only local variables, no closures etc.) Also, how these restrictions look like in practise.
My question comes from the fact that I know little about how the functions are represented in Python, so if anyone know a comprehensive text or video about this issue, it would help also.
Thank you.