lonelyenvoy/python-memoization

caching functions without arguments

bmc-msft opened this issue · 1 comments

Right now, syntax warning is generated with the following code.

@cached
def expensive_function():
   ...

However, the use of @cached in this context can be useful in some contexts. Example: @cached does effectively the same thing with significantly less code as the following construct using a global variable:

HAS_RUN=False
def expensive_function():
   global HAS_RUN
   if HAS_RUN:
      return
   else:
      HAS_RUN=True

Can this syntax warning be configurable and/or removed?

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

Please upgrade by: pip install -U memoization

The SyntaxWarning on functions without arguments has been removed.