James Bennett wrote: > While we're on the topic, the docs explicitly advise against doing > 'len' on a QuerySet because of the potential memory overhead of > loading all the objects, and recommend using the QuerySet's 'count' > method instead. Would it make more sense, then, to internally change > '__len__' on QuerySet to just return the result of 'self.count()' and > remove this potential hazard altogether?
The distinction was made on purpose. Tag {% for %} evaluates length of an iterable by doing len() and if this would call .count() then in most common case all queries accessed from templates will execute two request: "select count" and then "select" to actually output things. Now it only makes one select when doing len() and then uses newly cached results for output. --~--~---------~--~----~------------~-------~--~----~ You received this message because you are subscribed to the Google Groups "Django developers" group. To post to this group, send email to django-developers@googlegroups.com To unsubscribe from this group, send email to [EMAIL PROTECTED] For more options, visit this group at http://groups.google.com/group/django-developers -~----------~----~----~----~------~----~------~--~---