[DB-SIG] "lists of tuples" vs. "tuples of tuples"

Peter Eisentraut peter_e at gmx.net
Tue Feb 10 22:28:44 CET 2015

On 2/3/15 6:10 PM, Michael Bayer wrote:
> It’s mostly an issue of semantic correctness. A tuple implies a certain kind
> of role for a data structure. From a “Does it work?” perspective, there’s
> really no problem at all, except if we’re concerned about applications that
> assume the return of fetchall() is mutable. Python is in often enthusiastic
> about this kind of thing in general, from pep8 to naming conventions to
> everything else (to pointing out in the Python docs what the usual
> role of tuples is). But there’s no pressing issue here other than that.

As far as DB-API is concerned, it might be worth specifying that the
result values from fetchall etc. may be immutable.  I'm not sure if
anything would break from that, though.

Other than that, Python is not Haskell, and we're not going to succeed
legislating "usual" or "semantic" differences between tuples and lists.
 The differences are what they are, and users are free to exploit them
any way they want to.

More information about the DB-SIG mailing list