From c8bc2fdd4dd24dbe28d384306cf6096469e9f3e4 Mon Sep 17 00:00:00 2001 From: Adam Sampson Date: Wed, 28 Jan 2009 13:28:44 +0000 Subject: [PATCH] Remove a custom-comparison sort of the feed list. This was expensive because it was doing HTML sanitisation twice for each comparison; removing it shaves another 18 seconds (out of 30 spent in get_main_template_bits) off the write time for my test setup. --- NEWS | 9 ++++++--- rawdoglib/rawdog.py | 7 ++++--- 2 files changed, 10 insertions(+), 6 deletions(-) diff --git a/NEWS b/NEWS index a81fbe3..8330f9b 100644 --- a/NEWS +++ b/NEWS @@ -1,8 +1,11 @@ - rawdog 2.12 -Cache the result of locale.getpreferredencoding(), and rewrite -encode_references() to use regexps. This significantly speeds up writing -output files. +Several changes as a result of profiling that significantly speed up +writing output files: + +- Make encode_references() use regexp replacement. +- Cache the result of locale.getpreferredencoding(). +- Use tuple lists rather than custom comparisons when sorting. Update feedparser to revision 291, which fixes the handling of elements (reported by Darren Griffith). diff --git a/rawdoglib/rawdog.py b/rawdoglib/rawdog.py index 79ab28b..a32f2b1 100644 --- a/rawdoglib/rawdog.py +++ b/rawdoglib/rawdog.py @@ -1407,9 +1407,10 @@ __description__ FeedRSSLast fetchedNext fetched after """ - feeds = self.feeds.values() - feeds.sort(lambda a, b: cmp(a.get_html_name(config).lower(), b.get_html_name(config).lower())) - for feed in feeds: + feeds = [(feed.get_html_name(config).lower(), feed) + for feed in self.feeds.values()] + feeds.sort() + for (key, feed) in feeds: print >>f, '' print >>f, '' + feed.get_html_link(config) + '' print >>f, 'XML' -- 2.35.1