aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorcedricbonhomme <devnull@localhost>2010-12-01 13:29:22 +0100
committercedricbonhomme <devnull@localhost>2010-12-01 13:29:22 +0100
commitd3f82cb6a2de0a0ddf5c7a2ac6ad38bd581bca36 (patch)
treebce43f83a7bae542925bbdccd9e64fd5e86bb2d6
parentPerformance optimization. Load of articles (utils.load_feed() function.) (diff)
downloadnewspipe-d3f82cb6a2de0a0ddf5c7a2ac6ad38bd581bca36.tar.gz
newspipe-d3f82cb6a2de0a0ddf5c7a2ac6ad38bd581bca36.tar.bz2
newspipe-d3f82cb6a2de0a0ddf5c7a2ac6ad38bd581bca36.zip
Performance improvement. collections.defaultdict used in order to sotr articles.
-rwxr-xr-xutils.py5
1 files 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
bgstack15