Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]
Groups > comp.lang.python > #103990 > unrolled thread
| Started by | Peter Otten <__peter__@web.de> |
|---|---|
| First post | 2016-03-03 21:58 +0100 |
| Last post | 2016-03-03 21:58 +0100 |
| Articles | 1 — 1 participant |
Back to article view | Back to comp.lang.python
This discussion starts older than the indexed window; earlier articles aren't shown. The article labeled Started by
below is the oldest one visible, not the original post.
Re: Caching function results Peter Otten <__peter__@web.de> - 2016-03-03 21:58 +0100
| From | Peter Otten <__peter__@web.de> |
|---|---|
| Date | 2016-03-03 21:58 +0100 |
| Subject | Re: Caching function results |
| Message-ID | <mailman.162.1457038699.20602.python-list@python.org> |
Pavel Volkov wrote: > Suppose, I have some resource-intensive tasks implemented as functions in > Python. > Those are called repeatedly in my program. > It's guranteed that a call with the same arguments always produces the > same return value. > I want to cache the arguments and return values and in case of repititive > call immediately return the result without doing expensive calculations. > The arguments and return values are almost always: > * ints > * floats > * tuple or lists of ints or floats > > I think Cache object will store data in a dictionary. > I'll convert lists to tuples before storing them. > > I'd also like to limit the size of the cache (in MB) and get rid of old > cached data. https://docs.python.org/dev/library/functools.html#functools.lru_cache The only thing that is missing is list-to-tuple conversion.
Back to top | Article view | comp.lang.python
csiph-web