This could rely on `partial(f)` if `deep=False`, For `deep=True` we should rely on one of the recipes here: - https://stackoverflow.com/questions/13503079/how-to-create-a-copy-of-a-python-function - https://stackoverflow.com/questions/6527633/how-can-i-make-a-deepcopy-of-a-function-in-python/30714299#30714299