> > > Style A:
> > > 
> > > if can_use_fast_path:
> > >   return "fast path result"
> > > # do slow stuff
> > > return "slow path result"
> > > 
> > > 
> > > Style B:
> > > 
> > > result = "fast path result"
> > > if !can_use_fast_path:
> > >   # do slow stuff
> > >   result = "slow path result"
> > > return result
> > 
> > How expensive is evaluating can_use_fast_path?
> 
>    Does it matter? It's got to be evaluated in either route. Assume
> that it's cheap compared to the cost of the slow path (otherwise it's
> not worth doing the test, of course...)

Hmm. I'd choose Style A since with Style B there's a chance I'd have to
discard one result and evaluate three things. Unless there's some
parallel funny-stuff... what's the probability of can_use_fast_path?

James

-- 
The Holy ettlz                              theholyet...@googlemail.com
PGP key ID: 03F94B5D
-----------------------------------------------------------------------

Attachment: signature.asc
Description: This is a digitally signed message part

-- 
Please post to: Hampshire@mailman.lug.org.uk
Web Interface: https://mailman.lug.org.uk/mailman/listinfo/hampshire
LUG URL: http://www.hantslug.org.uk
--------------------------------------------------------------

Reply via email to