Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Why require the keymaker to have the same signature? #8

Closed
johann-petrak opened this issue May 19, 2020 · 1 comment
Closed

Why require the keymaker to have the same signature? #8

johann-petrak opened this issue May 19, 2020 · 1 comment
Labels
priority-0-high This issue has a high priority size-small Easy work need to be done

Comments

@johann-petrak
Copy link

I have a use case where pretty much all mutable unhashable objects are used immutably/read-only and where many different functions can have all kinds of such objects, mixed with hashable objects.

For this, I want to simply use the id instead of the hash (actually combine the hash and ids of all parameters into a string and hash that), so a single keymaker with signature (*args, **kwargs) would be sufficient. However the library explicitly checks and disallows to use that which means I have to implement many functions with different signatures which all do exactly the same.

@lonelyenvoy lonelyenvoy added priority-0-high This issue has a high priority size-small Easy work need to be done labels Dec 19, 2020
@lonelyenvoy
Copy link
Owner

lonelyenvoy commented Aug 1, 2021

Resolved in v0.4.0. Now available at PyPI or GitHub Releases.

Please upgrade by: pip install -U memoization

The explicit check that enforces the same signature policy for the user function and the custom key maker has been removed. Now, for inconsistent signatures, it will print a suppressible SyntaxWarning:

Expected custom_key_maker to have the same signature as the function being cached.
Call memoization.suppress_warnings() before using @cached to remove this message.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
priority-0-high This issue has a high priority size-small Easy work need to be done
Projects
None yet
Development

No branches or pull requests

2 participants