Join GitHub today
GitHub is home to over 31 million developers working together to host and review code, manage projects, and build software together.Sign up
Generalized hashing of keys for memoization #1074
This approach isn't perfect but it will allow a lot more keys to be memoized than before (sets, lists, dictionaries). The main limitation is that composite values as dictionary keys are not allowed by the JSON spec.
Currently pandas Dataframes/Series and numpy arrays are allowed as mutables. In general you will want to support mutable types explicitly as using the
This PR isn't ready yet - I want to add a bunch of unit tests.
Just some quick examples/performance statistics:
Unsurprisingly, big keys hash slower than small keys (I expect most keys to be pretty small). Note that
Python 3 has an additional limitation - the
If we are happy to accept these limitations, the PR is ready to merge now the test have passed. Even with its caveats/holes, this approach greatly expands what can be memoized (before this PR, even a simple list wouldn't allow memoization).