On Tue, 14 Apr 2009 11:51:50 +0200 Morten Brekkevold morten.brekkevold@uninett.no wrote:
On another note: Does all this code _really_ need to use dictionary result rows? I don't know the internals of psycopg2's DictCursor, but I seems to me that it could be a real memory-waste to pull thousands of table rows as dictionary instances instead of simple tuples.
After stating this, I became a bit curious about the actual DictCursor implementation, of course.
It seems to be "properly" optimized, in that the cursor object caches a column name index after each query. Each DictRow object (which is what is returned by the fetch methods) keeps a reference to the column name index from the originating cursor, and uses this for lookups when the DictRow object is indexed by anything but integers.