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

Cache not invalidated when keyword argument is a function #71

Closed
lorenzwalthert opened this issue Aug 25, 2021 · 3 comments
Closed

Cache not invalidated when keyword argument is a function #71

lorenzwalthert opened this issue Aug 25, 2021 · 3 comments

Comments

@lorenzwalthert
Copy link

lorenzwalthert commented Aug 25, 2021

Hi, here is a follow up to #70. I am not very experienced in Python, so I hope this doesn't waste anyone's time 🤞.
I believe functions are hashable and the cache should be invalidated when a hashable input changes. Do you agree? Does not seem to be the case, even though the hash changes:

from cachier import cachier

def my_fun24(x):
    return x

print(hash(my_fun24))
#>>> 8786991674287

@cachier()
def x(f):
    return my_fun24(1)

print(x(my_fun24))
#>>> 1

# let's change the function...
def my_fun24(x):
    return 2 * x

# ... and verify the hash changes
print(hash(my_fun24))
#>>> 8786992186206

# but `x()` is using the cached value apparently
print(x(my_fun24))
#>>> 1
@shaypal5
Copy link
Collaborator

This is an often-requested feature which is way more complex than it seems initially.

This was discussed in the following issues:
#9
#34

And attempted in two separate pull requests:
#17 , which was merged and then had to be reverted due to issues #18 and #19
#35 , which was rejected for the same reasons.

I would absolutely LOVE it if you would like to make a contribution to help with this feature. If you would like to do so, however, you would have to start with getting up-to-date with past discussions, issues and attempted contributions. Read up and let me know what you think.

Finally, I'm closing this issue as it's a duplicate of #34 .
Please continue all related discussion there.

Cheers,
Shay

@lorenzwalthert
Copy link
Author

Thanks for the explanation. I won't be able to contribute unfortunately.

@shaypal5
Copy link
Collaborator

Totally understandable. :)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants