On Wednesday 09 December 2009 01:52:48 Jeremy Dunck wrote:
> On Tue, Dec 8, 2009 at 7:22 PM, Luke Plant <[email protected]>
>  wrote: ...
> 
> > However, it could be slightly more efficient in some cases,
> > because the entire QuerySet._result_cache does not necessarily
> > need to be filled - we can stop if we find a match, saving us the
> > work of building Model objects that might not be needed.
> 
> You could also inspect the item to see if it's an instance of the
> .model; if not, fast path False.
> 
> Which leads to a question of edge-case semantics -- "1 in qs"
>  checking for primary key value.  Good or bad?

I think it's much better to leave __contains__ just doing an '==' 
check, rather than anything clever which could surprise people.  (If 
the developer is doing a test which is always going to return False, 
it's a mistake, not an optimization opportunity).

That would turn your question into "should QuerySet.__eq__() allow 
comparisons to integers?", which to me is an obvious "no", since you 
can't make it symmetric.

Luke

-- 
"If something is hard, it's not worth doing." (Homer Simpson)

Luke Plant || http://lukeplant.me.uk/

--

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