diff options
| author | François Freitag <mail@franek.fr> | 2018-04-13 18:15:22 -0700 |
|---|---|---|
| committer | Tim Graham <timograham@gmail.com> | 2018-04-23 12:39:43 -0400 |
| commit | 3fca95e1ad5b355f7813b98c97a194a30f2ab47b (patch) | |
| tree | e8357bddc0c38b6035f2dbd03d67d45728ab7d82 /tests/staticfiles_tests/cases.py | |
| parent | 9ec77f3d6633691c9bbf31d10af2313689170c85 (diff) | |
Fixed #28312 -- Made ModelChoiceIterator.__len__() more memory-efficient.
Instead of loading all QuerySet results in memory, count the number of
entries. This adds an extra query when list() or tuple() is called on the
choices (because both call __len__() then __iter__()) but uses less
memory since the QuerySet results won't be cached. In most cases, the
choices will only be iterated on, meaning that __len__() won't be called
and only one query will be executed.
Diffstat (limited to 'tests/staticfiles_tests/cases.py')
0 files changed, 0 insertions, 0 deletions
