"Steve Juranich" <[EMAIL PROTECTED]> wrote in message news:[EMAIL PROTECTED] > Without fail, when I start talking with some of the "old-timers" > (people who have written code in ADA or Fortran), I hear the same > arguments that using "if" is "better" than using "try". I think that > the argument goes something like, "When you set up a 'try' block, you > have to set up a lot of extra machinery than is necessary just > executing a simple conditional."
I believe 'setting up a try block' is one bytecode (you can confirm this with dis.dis). It is definitely cheaper than making a function call in an if condition. Catching exceptions is the time-expensive part. For more, see my response to 'witte'. Terry J. Reedy -- http://mail.python.org/mailman/listinfo/python-list