From d3f82cb6a2de0a0ddf5c7a2ac6ad38bd581bca36 Mon Sep 17 00:00:00 2001 From: cedricbonhomme Date: Wed, 1 Dec 2010 13:29:22 +0100 Subject: Performance improvement. collections.defaultdict used in order to sotr articles. --- utils.py | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/utils.py b/utils.py index f95007b6..1c879b31 100755 --- a/utils.py +++ b/utils.py @@ -49,6 +49,7 @@ from datetime import datetime from string import punctuation from collections import Counter from collections import OrderedDict +from collections import defaultdict from StringIO import StringIO @@ -347,7 +348,7 @@ def load_feed(): # article_link, article_description, article_readed, like) # feeds[feed_id] = (nb_article, nb_article_unreaded, feed_image, # feed_title, feed_link, feed_site_link, mail) - articles, feeds = {}, OrderedDict() + articles, feeds = defaultdict(list), OrderedDict() if list_of_feeds != []: sha1_hash = hashlib.sha1() # Case-insensitive sorting @@ -378,7 +379,7 @@ def load_feed(): # add the informations about the current article # to the list of articles of the current feed - articles[feed_id] = articles.get(feed_id, []) + #articles[feed_id] = articles.get(feed_id, []) articles[feed_id].append(article_list) # informations about a feed -- cgit