[Python-ideas] Use `isinstance` check during exception handling
Chris Angelico
rosuav at gmail.com
Thu Nov 5 17:12:28 EST 2015
On Fri, Nov 6, 2015 at 9:03 AM, Andrew Barnert via Python-ideas
<python-ideas at python.org> wrote:
> It would be really nice if someone remembered _why_ the code is this way. It may be a performance issue—if the exception is raised in C code and handled in C code and never displayed, the exception object never gets used, so why waste time (and complicate the reference graph) creating one?
>
I have some recollection that it's most commonly hit when you're
working with StopIteration - an internal iterator raises it, a 'for'
loop catches it, and no instance is ever constructed.
ChrisA
More information about the Python-ideas
mailing list