﻿id	summary	reporter	owner	description	type	status	component	version	severity	resolution	keywords	cc	stage	has_patch	needs_docs	needs_tests	needs_better_patch	easy	ui_ux
4399	Add __nonzero__ to allow querysets to efficiently test for emptiness	Michael Axiak <axiak@…>	Adrian Holovaty	"
Currently, if you do:
{{{
#!python
if Model.objects.filter(Complicated):
   ...
}}}
you're asking for performance trouble, since it will issue a {{{__len__}}} statement on it. Most people will solve this problem by doing:
{{{
#!python
if Model.objects.filter(Complicated).count() > 0:
   ...
}}}

But this is '''still''' much slower than doing a SELECT LIMIT 1. Thus, I propose adding a {{{__nonzero__}}} function, so that the first method of checking for emptiness does the right thing. (http://docs.python.org/ref/customization.html)"		closed	Database layer (models, ORM)	dev		duplicate	database,performance,existence,patch	axiak@…	Unreviewed	1	0	0	0	0	0
