On Feb 18, 2009, at 02:13, Malcolm Tredinnick wrote:

>
> On Tue, 2009-02-17 at 18:57 -0600, Jeremy Dunck wrote:
>> On Tue, Feb 17, 2009 at 6:49 PM, Malcolm Tredinnick
>> <[email protected]> wrote:
>> ...
>>> I'd be somewhat against this, I think. It's *very* easy to reuse
>>> querysets and inadvertently cause extra database queries.
>> ...
>>> we're trading memory
>>> usage for speed and ease of use (and providing a way to improve the
>>> former in "expert mode").
>>
>> Point taken.
>>
>> I wish there were some way to issue a warning if _result_cache is
>> filled but __iter__ isn't used more than once.  :-/
>
> Possible. Requires relying on __del__ being called so that we know  
> when
> it's not being used any longer. I prefer your other option, however.


Well, since __del__ messes with cyclic GC, one could also make a tool  
that tracks instances of weakref(QuerySets made, created_at), and at  
the end of each request, print out a list of querysets which were  
never reused.

But you'd probably end up finding a lot of cases where, in the future,  
a cache would help you. And you could start getting the opposite  
issue, which is what the result cache alleviates: many queries.

Which begs the question, would it even be interesting to know if an QS  
makes an iterator out of itself more than once? Easy to implement, hm  
hm.

I think I'll play around with these two ideas next Someday.

- Ludvig

--~--~---------~--~----~------------~-------~--~----~
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?hl=en
-~----------~----~----~----~------~----~------~--~---

Reply via email to