On Jul 13, 6:53 pm, Larry Bates <[EMAIL PROTECTED]> wrote:
> [EMAIL PROTECTED] wrote:
> > bukzor:
> >> You need to use two dictionaries. Here's a class that someone's
> >> written that wraps it up into a single dict-like object for you:
> >>http://www.faqts.com/knowledge_base/view.phtml/aid/4376
>
> > It contains code like:
>
> > try:
> >     del self.data[item]
> > except KeyError:
> >     pass
>
> > Exceptions are useful in python, but with dictionaries this is
> > probably faster (and shorter), even if it may perform two lookups:
>
> > if item in self.data:
> >     del self.data[item]
>
> > Bye,
> > bearophile
>
> The only case where it would be faster would be if most of the keys were NOT 
> in
> the dictionary (rather odd use case).  Otherwise I believe you will find the
> first way quicker as the exceptions are infrequent.
>
> -Larry

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

Reply via email to