#2632: [patch] Clearer, faster _dict_helper()
------------------------------------------------+---------------------------
 Reporter:  Andy Dustman <[EMAIL PROTECTED]>  |       Owner:  adrian
     Type:  enhancement                         |      Status:  new   
 Priority:  normal                              |   Milestone:        
Component:  Database wrapper                    |     Version:        
 Severity:  trivial                             |    Keywords:        
------------------------------------------------+---------------------------
 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.

-- 
Ticket URL: <http://code.djangoproject.com/ticket/2632>
Django <http://code.djangoproject.org/>
The web framework for perfectionists with deadlines.
--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups 
"Django updates" group.
To post to this group, send email to [email protected]
To unsubscribe from this group, send email to [EMAIL PROTECTED]
For more options, visit this group at 
http://groups.google.com/group/django-updates
-~----------~----~----~----~------~----~------~--~---

Reply via email to