MCPcopy
hub / github.com/django/django / __iter__

Method __iter__

django/db/models/query.py:419–435  ·  view source on GitHub ↗

The queryset iterator protocol uses three nested iterators in the default case: 1. sql.compiler.execute_sql() - Returns 100 rows at time (constants.GET_ITERATOR_CHUNK_SIZE) using cursor.fetchmany(). This part is responsible for

(self)

Source from the content-addressed store, hash-verified

417 return len(self._result_cache)
418
419 def __iter__(self):
420 """
421 The queryset iterator protocol uses three nested iterators in the
422 default case:
423 1. sql.compiler.execute_sql()
424 - Returns 100 rows at time (constants.GET_ITERATOR_CHUNK_SIZE)
425 using cursor.fetchmany(). This part is responsible for
426 doing some column masking, and returning the rows in chunks.
427 2. sql.compiler.results_iter()
428 - Returns one row at time. At this point the rows are still just
429 tuples. In some cases the return values are converted to
430 Python values at this location.
431 3. self.iterator()
432 - Responsible for turning the rows into model objects.
433 """
434 self._fetch_all()
435 return iter(self._result_cache)
436
437 def __aiter__(self):
438 # Remember, __aiter__ itself is synchronous, it's the thing it returns

Callers 2

_async_generatorMethod · 0.45
__iter__Method · 0.45

Calls 1

_fetch_allMethod · 0.95

Tested by

no test coverage detected