[issue24969] functools.lru_cache: a way to set decorator arguments at runtime

Marek Otahal report at bugs.python.org
Mon Aug 31 18:15:19 CEST 2015


Marek Otahal added the comment:

EDIT: 
> i.foo_long(1337)

ofc, this should be: 
i.foo_long('hi', cacheSize=1337)

or for (2): 

class MyLib():
  def __init__(arg1, arg2):
    self._cacheSize = someComputation(arg1, arg2) # returns a number
  @lru_cache
  def foo_long(self, arg1, **kwds):
    pass
#user
import MyLib 
i = MyLib(100, 21)
# not to make it so simple: 
i.changeInternalStateSomehow() # updates arg1, arg2, and also _cacheSize
i.foo_long(1337, cacheSizeName='_cacheSize') # ref to self._cacheSize

----------

_______________________________________
Python tracker <report at bugs.python.org>
<http://bugs.python.org/issue24969>
_______________________________________


More information about the Python-bugs-list mailing list