On Mon, 21 Jan 2008 01:15:50 -0800, dg.google.groups wrote:

> Decided I may as well post my other solution while I'm at it. The neat
> trick here is redefining the add, mul, etc. functions so that they raise
> exceptions for example if x>y then add(x,y) raises an exception which is
> handled by the search algorithm to mean don't continue that computation
> - this stops you from having to evaluate x+y AND y+x, etc.

Setting up a try...except block is very fast, but actually responding to 
an exception is very slow. You _might_ find that it is quicker to 
evaluate both expressions than it is to catch the exception.

Better still is to find another way of avoiding both the exception and 
the symmetrical calls.


-- 
Steven
-- 
http://mail.python.org/mailman/listinfo/python-list

Reply via email to