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

Memoizing None #25

Open
unformatt opened this issue Mar 22, 2018 · 0 comments
Open

Memoizing None #25

unformatt opened this issue Mar 22, 2018 · 0 comments

Comments

@unformatt
Copy link

unformatt commented Mar 22, 2018

I see this PR which adds support for memoizing None #17 but it seems that some refactoring later might have broken it?

>>> python ./manage.py shell

from memoize import memoize

@memoize()
def a(x):
    print 'a not memoized'
    if x == 1:
        return None
    return 'foo'

a(2)
a(2)
a(1)
a(1)

image

Seems to be cause by cache.get specifying a default if None is the value:

def get(self, key):
        "Proxy function for internal cache object."
        return self.cache.get(key=key, default=self.default_cache_value)
@unformatt unformatt changed the title Deployed 2.1.0 package doesn't seem updated Memoizing None Mar 22, 2018
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant