Django

Code

Ticket #5275: 5275.diff

File 5275.diff, 1.0 kB (added by ubernostrum, 1 year ago)

Patch documenting QuerySet.iterator()

  • docs/db-api.txt

    old new  
    948948 
    949949If you pass ``in_bulk()`` an empty list, you'll get an empty dictionary. 
    950950 
     951``iterator()`` 
     952~~~~~~~~~~~~ 
     953 
     954Evaluates the ``QuerySet`` (by performing the query) and returns an 
     955`iterator`_ over the results. A ``QuerySet`` typically reads all of 
     956its results and instantiates all of the corresponding objects the 
     957first time you access it; ``iterator()`` will instead read results and 
     958instantiate objects in discrete chunks, yielding them one at a 
     959time. For a ``QuerySet`` which returns a large number of objects, this 
     960often results in better performance and a significant reduction in 
     961memory use. 
     962 
     963Note that using ``iterator()`` on a ``QuerySet`` which has already 
     964been evaluated will force it to evaluate again, repeating the query. 
     965 
     966.. _iterator: http://www.python.org/dev/peps/pep-0234/ 
     967 
    951968``latest(field_name=None)`` 
    952969~~~~~~~~~~~~~~~~~~~~~~~~~~~ 
    953970