continue and break frustration

Paul Rubin http
Sun Dec 14 00:44:52 EST 2003


Glen Wheeler <adsl5lcq at tpg.com.au> writes:
>   I've been coding in python for a reasonable amount of time now
> (coding in total for approx. 20 years) and am writing a performance
> intensive program in python.
>   The problem I'm having is I want to use break and continue to get
> out from more than one level of loop.  If I set a variable and then
> check it my program will take too much of a performance hit.
>   Are there any alternatives people can think of?

Raise an exception and catch it.  However, if your function is that
sensitive to a little thing like that, maybe you need to write it
differently, for example in Pyrex or as a C extension.  You could
also try the Psyco compiler.




More information about the Python-list mailing list