Skip to content
This repository

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse code

Fixed #2662 -- Changed dictfetchmany and dictfetchall to return itera…

…tors,

rather than a list, in order to save memory. Patch from Simon Willison.


git-svn-id: http://code.djangoproject.com/svn/django/trunk@3783 bcc190cf-cafb-0310-a4f2-bffc1f526a37
  • Loading branch information...
commit 4f63ce5b4a625c15718c676f5efb78e0ffa282f5 1 parent 4b5f0e2
Malcolm Tredinnick authored September 22, 2006

Showing 1 changed file with 4 additions and 2 deletions. Show diff stats Hide diff stats

  1. 6  django/db/backends/util.py
6  django/db/backends/util.py
@@ -110,9 +110,11 @@ def dictfetchone(cursor):
110 110
 def dictfetchmany(cursor, number):
111 111
     "Returns a certain number of rows from a cursor as a dict"
112 112
     desc = cursor.description
113  
-    return [_dict_helper(desc, row) for row in cursor.fetchmany(number)]
  113
+    for row in cursor.fetchmany(number):
  114
+        yield _dict_helper(desc, row)
114 115
 
115 116
 def dictfetchall(cursor):
116 117
     "Returns all rows from a cursor as a dict"
117 118
     desc = cursor.description
118  
-    return [_dict_helper(desc, row) for row in cursor.fetchall()]
  119
+    for row in cursor.fetchall():
  120
+        yield _dict_helper(desc, row)

0 notes on commit 4f63ce5

Please sign in to comment.
Something went wrong with that request. Please try again.