A RetroSearch Logo

Home - News ( United States | United Kingdom | Italy | Germany ) - Football scores

Search Query:

Showing content from https://mail.python.org/pipermail/python-dev/2010-September/103458.html below:

[Python-Dev] new LRU cache API in Py3.2

[Python-Dev] new LRU cache API in Py3.2 [Python-Dev] new LRU cache API in Py3.2Stefan Behnel stefan_ml at behnel.de
Sat Sep 4 10:28:45 CEST 2010
Hi,

reading the description of the new LRU cache in the "What's new in 3.2" 
document now, I got the impression that the hits/misses attributes and the 
.clear() method aren't really well namespaced. When I read

     get_phone_number.clear()

it's not very obvious to me what happens, unless I know that there actually 
*is* a cache involved, which simply has the same name as the function. So 
this will likely encourage users to add a half-way redundant comment like 
"clear the cache" to their code.

What about adding an intermediate namespace called "cache", so that the new 
operations are available like this:

     print get_phone_number.cache.hits
     get_phone_number.cache.clear()

?

It's just a little more overhead, but I think it reads quite a bit better.

Stefan


More information about the Python-Dev mailing list

RetroSearch is an open source project built by @garambo | Open a GitHub Issue

Search and Browse the WWW like it's 1997 | Search results from DuckDuckGo

HTML: 3.2 | Encoding: UTF-8 | Version: 0.7.4