Re: [Hampshire] Code style

Startseite
Autor: The Holy ettlz
Datum:  
To: Hampshire LUG Discussion List
Betreff: Re: [Hampshire] Code style

Nachricht beantworten
gpg: failed to create temporary file '/var/lib/lurker/.#lk0x578db100.hantslug.org.uk.30409': Permission denied
gpg: keyblock resource '/var/lib/lurker/pubring.gpg': Permission denied
gpg: verify signatures failed: Unknown system error
On Sun, 2009-06-07 at 20:01 +0100, Hugo Mills wrote:
> If you were writing a function with a fast path and a slow path,
> which style would you use to write the function?
>
>
> 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?

James

-- 
The Holy ettlz                              TheHolyettlz@???
PGP key ID: 03F94B5D
-----------------------------------------------------------------------