mfenniak / pg8000

A Pure-Python PostgreSQL Driver
http://pythonhosted.org/pg8000/
Other
222 stars 55 forks source link

Fetchall returns a tuple of lists rather than a list of tuples #163

Closed aahaselgrove closed 5 years ago

aahaselgrove commented 6 years ago

When I execute a query and call fetchall, the funtion returns a tuple, where each element is a list representing a row of the result. Wouldn't it make more sense to be the other way around (i.e. a list of tuples)?

fdosani commented 6 years ago

Totally agree. +1

auscompgeek commented 6 years ago

It looks like the row-as-list is constructed here:

https://github.com/mfenniak/pg8000/blob/60fbf74147709ab52f89a31fbaeda8194a10cec4/pg8000/core.py#L1972-L1983

The tuple is constructed here:

https://github.com/mfenniak/pg8000/blob/60fbf74147709ab52f89a31fbaeda8194a10cec4/pg8000/core.py#L976

tlocke commented 5 years ago

Hi all, I've taken the approach of using the quickest data structure for the situation. I think it's about 10% slower to create a list than a tuple if it's created all in one go. I'm happy to be argued into changing it, but this is the reason for the decision.