Luke Lee

Software Engineer

Web + Desktop + Science

Fork me on Github

Performance of different Python error handling

Most programmers are familiar with the two common ways of dealing with errors:

  1. Look before you leap
  2. Easier to ask forgiveness than permission

Ever wonder which is faster?

I often catch myself thinking about the performance of these two strategies in my everyday Python coding. Of course, the performance of these is dependent on a number of things, namely the ratio of times you expect something to fail.

This is probably not a foreign concept to any experienced developer, but I stumbled on a great Stackoverflow answer that summarized this quite well. Give it a quick read, it's worth a refresher.

Published: 12-20-2012 19:31:00