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

Documentation issue around memoize and identity? #555

Open
lswainemoore opened this issue Feb 9, 2024 · 0 comments
Open

Documentation issue around memoize and identity? #555

lswainemoore opened this issue Feb 9, 2024 · 0 comments

Comments

@lswainemoore
Copy link

I suspect, based on a reading of the source code, that there may be a documentation mistake in the section on memoize. It says

Memoize is also designed for methods, since it will take into account the identity. of the ‘self’ or ‘cls’ argument as part of the cache key.

The link there goes to the python standard library id function, which refers to an object's location in memory. For e.g. a database object, this would be unique each time the object is loaded. However, when I look at the code, this appears to rely on the following function, found here:

def get_id(obj):
    return getattr(obj, "__caching_id__", repr)(obj)

The __caching_id__ or repr result would likely be much more stable. Can someone please confirm that this is how memoize is intended to work? If so, the documentation should be changed to remove the link (and ideally make mention of the correct interpretation of "identity")--I'd be happy to do so in that case.

Thanks!

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

No branches or pull requests

1 participant