On Tue, 2006-10-10 at 05:30 -0700, Andrew Durdin wrote:
> Malcolm Tredinnick wrote:
> >
> > The consistent design idea at work here is that a manager provides those
> > methods that return a Queryset object. That is why we have .all() in the
> > first place: it provides a way to convert from a manager object to a
> > Queryset without applying any filters or restrictions at all to the
> > default.
> 
> I guessed that might have been the case, but became less sure when I
> saw that Manager implementes iterator()  (which does not return a
> QuerySet).  It seemed natural to me to support __iter__ delegating to
> iterator(), but from what you say, I guess the latter is an exception
> that doesn't set a precedent :)

That's true. I'd forgotten about iterator().

[Time passes, as Malcolm reads the code a little bit...]

Interestingly, looking at QuerySet.iterator() and QuerySet.__iter__,
they aren't synonyms. The point is that QuerySet.__iter__ iterates over
the result of QuerySet._get_data(), which actually sucks everything into
memory before iterating. On the other hand, QuerySet.iterator() is a
more memory-conscious thing, iterating over each row at a time,
returning it as it is retrieved. I'm not sure if this is just an
accidental implementation issue or something intentional, but it's going
to make me use iterator() a bit more explicitly in at least one case I
can think of. Hmm.. the things you learn when you take the time to read
the source...

Whilst mapping Manager.__iter__ to Manager.iterator() would seem to make
sense on one level, it will then behave differently to
QuerySet.__iter__.

So now I'm just confused as to what might be "best". Certainly two sides
to this. I probably prefer the current consistency a little more, but
then there's iterator(). So I'm going to do the professional thing here:
hope that Adrian or Jacob has a strong opinion.

Regards,
Malcolm


--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups 
"Django developers" group.
To post to this group, send email to [email protected]
To unsubscribe from this group, send email to [EMAIL PROTECTED]
For more options, visit this group at 
http://groups.google.com/group/django-developers
-~----------~----~----~----~------~----~------~--~---

Reply via email to