[issue13177] Avoid chained exceptions in lru_cache

Ezio Melotti report at bugs.python.org
Fri Oct 14 14:19:11 CEST 2011


New submission from Ezio Melotti <ezio.melotti at gmail.com>:

The attached patch changes lru_cache to use if/else instead of try/except.
This has 2 effects:
1) it avoids chained exceptions and makes the error messages clearer;
2) it probably makes lru_cache a bit faster since building and catching exceptions is expensive. It also gets rid of the KeyError=KeyError optimization/hack;

For a couple of examples of 1) see #12749 (msg142059, msg142063), or #13169 (msg145469).  See also related issue #6210.

----------
assignee: rhettinger
files: issue13177.diff
keywords: needs review, patch
messages: 145511
nosy: ezio.melotti, rhettinger
priority: normal
severity: normal
stage: patch review
status: open
title: Avoid chained exceptions in lru_cache
type: behavior
versions: Python 3.2, Python 3.3
Added file: http://bugs.python.org/file23403/issue13177.diff

_______________________________________
Python tracker <report at bugs.python.org>
<http://bugs.python.org/issue13177>
_______________________________________


More information about the Python-bugs-list mailing list