Re: Use generators instead of lists for resultsets?

Faber <[email protected]> Sat, 25 Jun 2005 03:07:06 +0200
Newsgroups gmane.comp.web.skunkweb
Organization FaberBox
Message-ID <[email protected]>
On Friday 24 June 2005 21:45, Jacob Smullyan wrote:

[cut]

> I now think that both problems can be resolved by adding an additional
> method, called, say, iterSome().  You could then choose whether to use
> a generator which would call fetchone() on the cursor, or not.

I think that there could be better solutions to this problem; for example, 
adding an optional paramether to the getSome() method that specifies if the 
result should be a generator or a list (default to list). Moreover, there 
could be an attribute of PyDO derived classes that specifies the default 
behaviour.

This would solve the problem [more or less] smartly:

* If the user realyzes that most queries on a table are huge he would set 
the class member and all HugeResultsClass.getSome() calls would returns a 
generator, a list otherwise

* Let's assume that most queries of the application are small/mid size, the 
"list" default would be ok, and if the user should run a huge query in a 
particular function he could do e.g.

Products.getSome("Price > 20.0", returntype=pydogenerator)

(or something like that, with a better syntax of course  ;) )

I think it could be applied also for getDBI.execute() method.

Just my 0.02  ^__^

-- 
Faber
http://www.faberbox.com/

A problem is a chance for you to do your best. -- Duke Ellington


-------------------------------------------------------
SF.Net email is sponsored by: Discover Easy Linux Migration Strategies
from IBM. Find simple to follow Roadmaps, straightforward articles,
informative Webcasts and more! Get everything you need to get up to
speed, fast. http://ads.osdn.com/?ad_id=7477&alloc_id=16492&op=click