summaryrefslogtreecommitdiff
path: root/alot/db/manager.py
diff options
context:
space:
mode:
authorDylan Baker <dylan@pnwbakers.com>2016-12-20 11:36:26 -0800
committerDylan Baker <dylan@pnwbakers.com>2016-12-21 17:18:39 -0800
commitbf2005c111289fcd7f55b92e64cfa8c43b9bfdbc (patch)
treee851408464368cfcb173a491a3c4cef5b83888fa /alot/db/manager.py
parent899d3f4bb20441393182c3a5690566705e6b91aa (diff)
Don't use dict.keys when not necessary
It's pretty easy to get caught up using dict.keys (or iterkeys) when one doesn't need to. This patch corrects two cases where it's not needed, the first is the case of inclusion. ``x in mydict.keys()`` is equivalent to ``x in mydict``, but without the need to generate a list and walk it. The second case is when calling set() on a dict, ``set(mydict)`` will create a set object of the dict's keys, without the need to create one in memory and is significantly faster than ``set(mydict.keys())`` or even ``set(mydict.iterkeys())``.
Diffstat (limited to 'alot/db/manager.py')
-rw-r--r--alot/db/manager.py2
1 files changed, 1 insertions, 1 deletions
diff --git a/alot/db/manager.py b/alot/db/manager.py
index a1c0b8ed..3520ee63 100644
--- a/alot/db/manager.py
+++ b/alot/db/manager.py
@@ -381,7 +381,7 @@ class DBManager(object):
:rtype: (:class:`multiprocessing.Pipe`,
:class:`multiprocessing.Process`)
"""
- assert sort in self._sort_orders.keys()
+ assert sort in self._sort_orders
q = self.query(querystring)
q.set_sort(self._sort_orders[sort])
return self.async(q.search_threads, (lambda a: a.get_thread_id()))