Avoid tuple creation/split in the loop.
for key in sorted(blog):
for blog_post in sorted(blog[key]):
if current_blog_post:
- prev_key, prev_blog_post = current_key, current_blog_post
+ prev_key = current_key
+ prev_blog_post = current_blog_post
if next_blog_post:
- current_key, current_blog_post = next_key, next_blog_post
+ current_key = next_key
+ current_blog_post = next_blog_post
next_key = key
next_blog_post = blog_post
if current_blog_post and (current_key == ymd) and \