News for hackers. Stuff that matters.
Re:Python Practices for Efficient Code: Performance, Memory,... by pfranz on Friday August 18, 2017 @10:04PM (#15051222)
That's what I was trying to get at. Not to avoid exceptions, but to write your code in such a way that exceptions are rare. I usually encounter it with file i/o situations, like like you're saying, an extra file stat in a loop would be really slow and open you to race conditions (file being modified before testing an acting). If an exception was thrown 90% of the time, you want to rethink your logic because performance might be equally poor. Catching the rare exception is ideal.

As an aside (since you mentioned generators), I wish exception handling in comprehensions were easier to deal with.

There are no comments on this comment yet.