Re: Re: Use generators instead of lists for resultsets?

Jacob Smullyan <[email protected]> Sat, 25 Jun 2005 09:35:42 -0400
Newsgroups gmane.comp.web.skunkweb
Message-ID <[email protected]>
On Sat, Jun 25, 2005 at 10:50:11AM +0200, Jeroen van Dongen wrote:
> Instead of doing a fetchone we could use
> fetchmany([size=cursor.arraysize]), with getSome growing an extra option
> that specifies what chunksize to use?

iterSome() could use fetchmany().  An extra getSome/iterSome option
would be a problem (for reasons discussed in my long post yesterday),
so I'm not sure how to control the chunksize; a class attribute would
work much of the time, but you might want to increase the chunksize
for a projection, in which case you'd have to do:

   p=obj.project('id', 'fruitcake')
   p.chunksize=1048
   for z in p.iterSome():
	# etc.

Even though it might not be necessary, controlling chunksize per query
would be nicer.  You could use a proxy object, but it is awkward:

   g=obj.chunksize(1048).iterSome()

What about:

   g=obj.iterSome()
   g.chunksize=1048
   for r in g:
       # etc.

I'm not thrilled by any of these alternatives.

j

-- 
Jacob Smullyan
signature.asc (application/pgp-signature, 189 B)
-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.4.1 (GNU/Linux)

iD8DBQFCvV2uuqamFyFXXLIRAi9wAKCI6YSIoAOstALkYvxhf3IfSIZWGwCfV4zn
BJdw5iHFyjTtqQ4rjbuvfDA=
=3JqU
-----END PGP SIGNATURE-----