From b1dcf4054b8313b366550a3ec1e6dbccc0415e31 Mon Sep 17 00:00:00 2001 From: Joshua Nahum Date: Sun, 2 Dec 2012 02:37:48 -0800 Subject: [PATCH] Changed lookup in dictionaries to sets and set comprehension --- docs/writing/style.rst | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/docs/writing/style.rst b/docs/writing/style.rst index 2d6316e5f..3ccdb3034 100644 --- a/docs/writing/style.rst +++ b/docs/writing/style.rst @@ -327,22 +327,22 @@ A common idiom for creating strings is to use `join `_ page. +Even though both functions look identical, because *lookup_set* is utilizing the fact that sets in python are hashtables, the lookup performance between the two is very different. +Python will have to go through each item in the list to find a matching case, which is time consuming. By analysing the hash of the items in the set can be done very quickly. +For more information see this `StackOverflow `_ page. Note: python dictionaries and sets have the lookup performance. Zen of Python -------------