End of file

Nick Craig-Wood nick at craig-wood.com
Fri Oct 8 09:29:59 EDT 2004


Alex Martelli <aleaxit at yahoo.com> wrote:
>  Nick Craig-Wood <nick at craig-wood.com> wrote:

[snip good advice re backwards compatibility]

> > Its also half the speed and 4 times the typing
[snip]
> > But who's counting ;-)
> 
>  Nobody, I sure hope.  's=[]' is just four characters, while 'sentinel =
>  []', the usage you suggested (with proper spacing and a decent name), is
>  13, and yet it's pretty obvious the clarity of the latter is well worth
>  the triple typing; and if going to 'sentinel = object()' makes it
>  clearer yet, the lesser move from 13 to 19 (an extra-typing factor of
>  less than 1.5) is similarly well justified.
>  And I think it's unlikely you'll need so many sentinels as to notice the
>  extra 300 nanoseconds or so to instantiate each of them...

My toungue was firmly in cheek as I wrote that as I hope the smiley
above indicated!  I timed the two usages just to see (and because
timeit makes it so easy).  Indeed what is 6 characters and 300 nS
between friends ;-)

I shall put the object() as sentinel trick in my toolbag where it
belongs!

-- 
Nick Craig-Wood <nick at craig-wood.com> -- http://www.craig-wood.com/nick



More information about the Python-list mailing list