From: | Federico Di Gregorio <federico(dot)digregorio(at)dndg(dot)it> |
---|---|
To: | Daniele Varrazzo <daniele(dot)varrazzo(at)gmail(dot)com> |
Cc: | psycopg(at)postgresql(dot)org |
Subject: | Re: Proposal: efficient iter on named cursors |
Date: | 2011-02-17 11:09:10 |
Message-ID: | 4D5D01D6.8030607@dndg.it |
Views: | Raw Message | Whole Thread | Download mbox | Resend email |
Thread: | |
Lists: | psycopg |
On 17/02/11 11:57, Daniele Varrazzo wrote:
>> I think the original implementation was right because "foreach ..."
>> > doesn't mean fetch one record at a time. IMHO,
>> >
>> > 1) .fetchone() should _always_ fetch one record
>> > 2) iter(cursor) should fetch as many records as we feel right
> Yes, this is what I think too. It is consistent with what happens with
> iter(file) vs. file.readline(). The only hitch is that the DBAPI asks
> for a default of 1 for arraysize.
>
>
>> > But we can do a little trick here and make iter(cursor) respect
>> > .arraysize if arraysize was explicitly set so that if one really wants
>> > to fetch one record at a time can just set .arraysize to 1.
>> >
>> > Good or bad?
> Quite tricky as arraysize is currently a simple property. Even if we
> could do it with some property trickery, it would be surprising if
> "print cur.arraysize" would return 1 and iter(cur) was efficient;
> then, after "cur.arraysize = 1", iter(cur) would switch to fetch one
> record at time, while "print cur.arraysize" would still report 1. I
> feel it violates the principle of least astonishment, as much as being
> difficult for the user to predict what the library would do.
Then we need a different property: itersize?
federico
--
Federico Di Gregorio federico(dot)digregorio(at)dndg(dot)it
Studio Associato Di Nunzio e Di Gregorio http://dndg.it
Io non sono romantica. La candelina sul tavolo mi vede e si spegne.
-- sisterconfusion
From | Date | Subject | |
---|---|---|---|
Next Message | Daniele Varrazzo | 2011-02-17 11:12:12 | Re: Proposal: efficient iter on named cursors |
Previous Message | Daniele Varrazzo | 2011-02-17 10:57:37 | Re: Proposal: efficient iter on named cursors |