looking before leaping - Python Dict: Unscientific benchmarks of lookup methods
Marius Kruger
amanic at gmail.com
Tue Jun 28 14:01:48 UTC 2011
On 28 June 2011 15:26, John Meinel <john at arbash-meinel.com> wrote:
> The rough guidelines I've found:
>
> 1) use pyrex if it really matters
> 2) use try/d[x]/except if you know that the keys are almost always there
> (eg counting types)
> 3) use if x in d: d[x] if hit rate is low
> 4) avoid extra attribute lookups, especially in list comprehensions
>
It is great to have rule of thumb like this, thanks.
--
<>< Marius ><>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <https://lists.ubuntu.com/archives/bazaar/attachments/20110628/f1352f08/attachment.html>
More information about the bazaar
mailing list