diff options
author | cedricbonhomme <devnull@localhost> | 2010-12-01 13:29:22 +0100 |
---|---|---|
committer | cedricbonhomme <devnull@localhost> | 2010-12-01 13:29:22 +0100 |
commit | d3f82cb6a2de0a0ddf5c7a2ac6ad38bd581bca36 (patch) | |
tree | bce43f83a7bae542925bbdccd9e64fd5e86bb2d6 /utils.py | |
parent | Performance optimization. Load of articles (utils.load_feed() function.) (diff) | |
download | newspipe-d3f82cb6a2de0a0ddf5c7a2ac6ad38bd581bca36.tar.gz newspipe-d3f82cb6a2de0a0ddf5c7a2ac6ad38bd581bca36.tar.bz2 newspipe-d3f82cb6a2de0a0ddf5c7a2ac6ad38bd581bca36.zip |
Performance improvement. collections.defaultdict used in order to sotr articles.
Diffstat (limited to 'utils.py')
-rwxr-xr-x | utils.py | 5 |
1 files changed, 3 insertions, 2 deletions
@@ -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 |