Josh Rosenberg added the comment:

The main example that comes to mind was a variant of functools.lru_cache I 
wrote that expired cache entries after they reached a staleness threshold. The 
details elude me (this was a work project from a year ago), but it was 
basically what I was describing; a case where I wanted to efficiently, 
destructively iterate a collections.deque, and it would have been nice to be 
able to do so without needing a lock (at least for that operation) and without 
(IMO) ugly infinite loops terminated by an exception. (Caveat: Like I said, 
this was a while ago; iter_except might only have simplified the code a bit, 
not saved me the lock)

No, it's not critical. But for a lot of stuff like this, the recipe saves 
nothing over inlining a while True: inside a try/except, and people have to 
know the recipe is there to even look for it. The only reason my particular 
example came to mind is that the atomic aspect was mildly important in that 
particular case, so it stuck in my head (normally I'm not trying to squeeze 
cycles out of Python, but performance oriented decorators are a special case). 
I do stuff that would be simplified by this more often, it's just cases where I 
currently do something else would all be made a little nicer if I could have a 
single obvious way to accomplish it that didn't feel oddly verbose/ugly.

----------

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

Reply via email to