Ezio Melotti <ezio.melo...@gmail.com> added the comment: Here's an example (copied from msg142063) of what the traceback is without the patch: >>> from functools import lru_cache >>> @lru_cache() ... def func(arg): raise ValueError() ... >>> func(3) Traceback (most recent call last): File "/home/wolf/dev/py/3.2/Lib/functools.py", line 176, in wrapper result = cache[key] KeyError: (3,)
During handling of the above exception, another exception occurred: Traceback (most recent call last): File "<stdin>", line 1, in <module> File "/home/wolf/dev/py/3.2/Lib/functools.py", line 180, in wrapper result = user_function(*args, **kwds) File "<stdin>", line 2, in func ValueError The patch gets rid of the first traceback (the one before "During handling..."). I should also mention that my second point might not be valid if the cache hits are mostly successful. I haven't done any specific benchmark, and I don't know how fast is 'key in dict' compared to raising an exception. If it's e.g. 10 times faster, it should make lru_cache faster when the hits:miss ratio is lower than 10:1. ---------- _______________________________________ Python tracker <rep...@bugs.python.org> <http://bugs.python.org/issue13177> _______________________________________ _______________________________________________ Python-bugs-list mailing list Unsubscribe: http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com