@@ -154,15 +154,16 @@ The :mod:`functools` module defines the following functions:
154
154
155
155
@lru_cache
156
156
def count_vowels(sentence):
157
- sentence = sentence.casefold()
158
- return sum(sentence.count(vowel) for vowel in 'aeiou')
157
+ return sum(sentence.count(vowel) for vowel in 'AEIOUaeiou')
159
158
160
159
If *maxsize * is set to ``None ``, the LRU feature is disabled and the cache can
161
160
grow without bound.
162
161
163
162
If *typed * is set to true, function arguments of different types will be
164
- cached separately. For example, ``f(3) `` and ``f(3.0) `` will be treated
165
- as distinct calls with distinct results.
163
+ cached separately. For example, ``f(3) `` and ``f(3.0) `` will always be
164
+ treated as distinct calls with distinct results. If *typed * is false,
165
+ the implementation will usually but not always regard them as equivalent
166
+ calls and only cache a single result.
166
167
167
168
The wrapped function is instrumented with a :func: `cache_parameters `
168
169
function that returns a new :class: `dict ` showing the values for *maxsize *
@@ -172,8 +173,7 @@ The :mod:`functools` module defines the following functions:
172
173
To help measure the effectiveness of the cache and tune the *maxsize *
173
174
parameter, the wrapped function is instrumented with a :func: `cache_info `
174
175
function that returns a :term: `named tuple ` showing *hits *, *misses *,
175
- *maxsize * and *currsize *. In a multi-threaded environment, the hits
176
- and misses are approximate.
176
+ *maxsize * and *currsize *.
177
177
178
178
The decorator also provides a :func: `cache_clear ` function for clearing or
179
179
invalidating the cache.
@@ -182,6 +182,9 @@ The :mod:`functools` module defines the following functions:
182
182
:attr: `__wrapped__ ` attribute. This is useful for introspection, for
183
183
bypassing the cache, or for rewrapping the function with a different cache.
184
184
185
+ The cache keeps references to the arguments and return values until they age
186
+ out of the cache or until the cache is cleared.
187
+
185
188
An `LRU (least recently used) cache
186
189
<https://en.wikipedia.org/wiki/Cache_replacement_policies#Least_recently_used_(LRU)> `_
187
190
works best when the most recent calls are the best predictors of upcoming
0 commit comments