On Wed, Jan 30, 2019 at 08:27:41PM -0600, Abe Dillon wrote:

> I've heard there's a non-insignificant performance penalty for setting up a
> try statement, so it might be important to only set a for-loop up as a
> guarded for-loop upon reading the "except" statement (if the compiler can
> handle such behavior).

I believe you have been misinformed. I admit I haven't tried it 
recently, but back in Python 2.5 days or so I ran some benchmarks which 
satisfied me that:

- the cost of setting up a try block was effectively zero;
- the cost of catching an exception is quite steep.

I'd be surprised if Python 3 reverses that.


-- 
Steven
_______________________________________________
Python-ideas mailing list
[email protected]
https://mail.python.org/mailman/listinfo/python-ideas
Code of Conduct: http://python.org/psf/codeofconduct/

Reply via email to