Skip to content

Calling a cached function with default arguments does not read from cache #339

@zmeir

Description

@zmeir

Given the following simple example:

@cachetools.cached(cachetools.Cache(maxsize=100))
def foo(a=1):
    print(a)

This is the result of calling foo(), foo(1) and foo(a=1):

>>> foo()
1
>>> foo()
>>> foo(1)
1
>>> foo(1)
>>> foo(a=1)
1
>>> foo(a=1)

One would expect that foo would only be executed once instead of 3 times:

>>> foo()
1
>>> foo()
>>> foo(1)
>>> foo(1)
>>> foo(a=1)
>>> foo(a=1)

Metadata

Metadata

Assignees

Labels

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions