
Michael Foord wrote:
Nick Coghlan wrote:
Note that using exceptions for control flow can be bad for other implementations of Python. For example exceptions on the .NET framework are very expensive. (Although there are workarounds such as not really raising the exception - but they're ugly).
Is it that exceptions are expensive, or setting up a try/except block is expensive? The reason the SkipStatement idea is tenable at all (even in CPython) is that try/except is fairly cheap when no exception is raised.
It is the raising of the exception that is expensive.
Then that isn't a huge drawback in this case - the SkipStatement exception is only used in situations which would currently probably be handled by raising an exception anyway (e.g. the change to contextlib.contextmanager.__enter__() in the patch is to raise SkipStatement where it currently raises RuntimeError). Cheers, Nick. -- Nick Coghlan | ncoghlan@gmail.com | Brisbane, Australia ---------------------------------------------------------------