From 84aa7599a44e78253b42a72e634601076d027b66 Mon Sep 17 00:00:00 2001 From: Mikhail Korobov Date: Thu, 19 Dec 2013 15:06:27 +0600 Subject: [PATCH] no need to use dict in scrapy.utils.python.unique --- scrapy/utils/python.py | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/scrapy/utils/python.py b/scrapy/utils/python.py index 20d4e6b5e..834773072 100644 --- a/scrapy/utils/python.py +++ b/scrapy/utils/python.py @@ -53,13 +53,13 @@ def flatten(x): def unique(list_, key=lambda x: x): """efficient function to uniquify a list preserving item order""" - seen = {} + seen = set() result = [] for item in list_: seenkey = key(item) - if seenkey in seen: + if seenkey in seen: continue - seen[seenkey] = 1 + seen.add(seenkey) result.append(item) return result @@ -70,7 +70,7 @@ def str_to_unicode(text, encoding=None, errors='strict'): object without the risk of double-decoding problems (which can happen if you don't use the default 'ascii' encoding) """ - + if encoding is None: encoding = 'utf-8' if isinstance(text, str):