• François Freitag's avatar
    Fixed #28312 -- Made ModelChoiceIterator.__len__() more memory-efficient. · 3fca95e1
    François Freitag yazdı
    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.
    3fca95e1
tests.py 113 KB