Matt Joiner <anacro...@gmail.com> added the comment:

I've fixed the commenting, and cache_info use.

I've left the element management in pure C as it reduces memory use (56 bytes 
for 4 element list, vs. 16 for lru_cache_elem), and avoids ref counting 
overhead (3 refs per link, plus GC). The difference might become quite marked 
for very large caches. There's also a nice invariant that links the key to the 
cache dict, and the result object to the lru_cache_elem. I'm happy to change 
this if it doesn't matter.

My only concern now is the wrapping of the lru cache object. In the Python 
version, @wraps allows the lru_cache to masquerade as the wrapped function wrt 
str/repr. The C version is wrapped, but str/repr remain unchanged. Not sure if 
this is a problem.

----------
Added file: http://bugs.python.org/file25026/functools.lru_cache-in-c.patch

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

Reply via email to