On Mon, 7 Nov 2011 12:03:46 +1000
Nick Coghlan
I'm not sure that it's still that important -- in fact I'm not sure Python 3 still has this behavior.
I'm fairly sure it does (it was the 3.x version of ceval that I was reading to remind myself of how the stack unwinding process actually works and the call to PyErr_NormalizeException() is still in there). It's just that without the multiple argument forms of the raise statement, pure Python code can only exploit it for exceptions without any arguments (so it still works for the StopIteration optimisation).
It's too late for me to go and take a look, but I'm not sure it does. Unless the performance loss is significant, I would be in favour of simplifying all this and always instantiating exceptions. Exception handling in the eval loop and exception "normalization" is a nasty area of the interpreter. Regards Antoine.