Raymond Hettinger added the comment:

> The problem is I can't know the optimal values for 'maxsize',
> I need to set them at runtime. 

The easiest way to go is to wait to start caching until you know the cache size 
you want:
   
   def foo(a, b, c):
        pass

   size = get_user_request()
   foo = lru_cache(foo, maxsize=size)

If there is a subsequent need to change the cache size, just rewrap it:

   size = get_user_request()
   original_function = foo.__wrapped__
   foo = lru_cache(foo, maxsize=size)

----------
priority: normal -> low

_______________________________________
Python tracker <rep...@bugs.python.org>
<http://bugs.python.org/issue24969>
_______________________________________
_______________________________________________
Python-bugs-list mailing list
Unsubscribe: 
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com

Reply via email to