Message145514
| Author |
ezio.melotti |
| Recipients |
ezio.melotti, rhettinger |
| Date |
2011年10月14日.13:27:21 |
| SpamBayes Score |
8.753863e-09 |
| Marked as misclassified |
No |
| Message-id |
<1318598842.26.0.635257036215.issue13177@psf.upfronthosting.co.za> |
| In-reply-to |
| Content |
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. |
|
History
|
|---|
| Date |
User |
Action |
Args |
| 2011年10月14日 13:27:22 | ezio.melotti | set | recipients:
+ ezio.melotti, rhettinger |
| 2011年10月14日 13:27:22 | ezio.melotti | set | messageid: <1318598842.26.0.635257036215.issue13177@psf.upfronthosting.co.za> |
| 2011年10月14日 13:27:21 | ezio.melotti | link | issue13177 messages |
| 2011年10月14日 13:27:21 | ezio.melotti | create |
|