#10291 closed (fixed)
Correction to QuerySet.iterator() documentation
Reported by: | Erin Kelly | Owned by: | nobody |
---|---|---|---|
Component: | Documentation | Version: | dev |
Severity: | Keywords: | ||
Cc: | Triage Stage: | Ready for checkin | |
Has patch: | yes | Needs documentation: | no |
Needs tests: | no | Patch needs improvement: | no |
Easy pickings: | no | UI/UX: | no |
Description
A revision to the documentation for the QuerySet.iterator() method that better reflects how it behaves differently from normal evaluation.
Attachments (1)
Change History (9)
by , 16 years ago
Attachment: | 10291.diff added |
---|
comment:1 by , 16 years ago
Triage Stage: | Unreviewed → Accepted |
---|
comment:2 by , 15 years ago
Has patch: | set |
---|---|
Triage Stage: | Accepted → Ready for checkin |
comment:3 by , 15 years ago
Resolution: | → invalid |
---|---|
Status: | new → closed |
I'm not sure this documentation change is correct/appropriate. The point of iterator()
is to do the query in chunks (as explained in the current document), not to avoid caching (as explained in the patch).
comment:4 by , 15 years ago
Resolution: | invalid |
---|---|
Status: | closed → reopened |
Reopening because I think Adrian's determination is incorrect. If I'm missing something, let me know and I'll drop it.
It's true that iterator()
fetches the query result in chunks, but normal evaluation using __iter__()
also fetches the query result in chunks. Also, any function applied to the result of __iter__()
that causes everything to be fetched will do the same when applied to the result of iterator()
.
In fact, __iter__()
invokes iterator()
behind the scenes to do the heavy lifting. The only thing it does differently is that it makes use of and fills the QuerySet's _result_cache
over the course of iteration. So if iterator()
is merely meant to fetch the query result in chunks, why is it even included in the public API when __iter__()
already accomplishes this?
comment:5 by , 15 years ago
Looking at the current code, I'm with ikelly on this one, I happened to be looking at this just now. The only thing that changes if you switch to iterator() is that your results will not be cached.
comment:6 by , 15 years ago
Resolution: | → fixed |
---|---|
Status: | reopened → closed |
comment:7 by , 15 years ago
comment:8 by , 15 years ago
Oops, meant to says "thanks ikelly" in that commit message, seeing as I used your patch wholesale. Cheers.
looks like a nice clarification to me