I know this is my code, but as we're moving out from dev to testing, this code scares me. key_override can have security implications. I would propose key_override should either be cut, or used instead of args/kwargs/name in s. It should be specific to f.__module__ and to memoize.