[DB-SIG] Python database API 2.0/returning Column names with data

David Bolen db3l@fitlinxx.com
Tue, 6 Nov 2001 13:09:13 -0500

Greg Stein [gstein@lyra.org] writes:

> However, unlike dtuple.py, you end up scanning the *entire* list of
> creating a dictionary for every row, and then appending that to a list
> (which may have to be resized multiple times).
> When I wrote dtuple umpteen million years ago, I had approached the
> similarly to what you did above. In real life scenarios, it just blew.
> Profiling the code showed the bottleneck was that loop. So dtuple was
> to have O(1) for creation, and defer the costly work to access time. And
> even then, it doesn't create objects -- it just looks them up.

Oh agreed.  Thus my plug for dtuple (which I do use, and appreciate
:-)).  But I think the sample code at least was a simple way to
describe how you could produce the structure the request wanted as a
way to highlighting the parts of the API (e.g., cursor.description)
you would use.

At least in my cases, with small to medium data sets, this approach hasn't
been a bottleneck but obviously mileage may vary.

> There are a million choices in implementation. Various tradeoffs in space
> and time, selections of algorithms, etc.

Yep, as this very thread highlights :-)

-- David

 \               David Bolen            \   E-mail: db3l@fitlinxx.com  /
  |             FitLinxx, Inc.            \  Phone: (203) 708-5192    |
 /  860 Canal Street, Stamford, CT  06902   \  Fax: (203) 316-5150     \