﻿id	summary	reporter	owner	description	type	status	component	version	severity	resolution	keywords	cc	stage	has_patch	needs_docs	needs_tests	needs_better_patch	easy	ui_ux
2632	[patch] Clearer, faster _dict_helper()	Andy Dustman <farcepest@…>	Adrian Holovaty	"Currently django.db.backends.util._dict_helper uses enumerate() and several index operations per column to build a dictionary result. It's much simpler and faster, since there's only one index operation per column vs. four with current implementation, and no intermediate list from enumerate():

{{{
Index: django/db/backends/util.py
===================================================================
--- django/db/backends/util.py  (revision 3682)
+++ django/db/backends/util.py  (working copy)
@@ -98,7 +98,7 @@

 def _dict_helper(desc, row):
     ""Returns a dictionary for the given cursor.description and result row.""
-    return dict([(desc[col[0]][0], col[1]) for col in enumerate(row)])
+    return dict(zip([col[0] for col in desc], row))

 def dictfetchone(cursor):
     ""Returns a row from the cursor as a dict""
}}}

Not that this is likely to be a big bottleneck in Django, but there's no downside."	enhancement	closed	Database layer (models, ORM)		trivial	fixed		farcepest@…	Unreviewed	1	0	0	0	0	0
