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

Michael Bayer mike_mp at zzzcomputing.com
Sun Feb 1 22:47:58 CET 2015

Hi -

May I get clarification from pep-249 regarding the contract for fetchall() and fetchmany(), as to if it is acceptable and/or recommended that these methods return tuples of tuples, as opposed to lists of tuples?

In my experience, while tuples and lists are just “sequences” that are immutable / mutable, there is a more subtle semantic distinction between them, in that lists are for variable-length collections of homogenous elements (e.g. rows), whereas tuples are appropriate for fixed-length collections of heterogenous elements (e.g. column values).  

If this is the case, pep-249’s use of the language "e.g. a list of tuples” leaves this open to interpretation and inconsistency, like so many other things.   I’d like to get some language, at least in email here, that lists are recommended, if this is the case.     Otherwise, I guess it’ll just be another thing for me to suggest for DBAPI-3 :).

thanks for your attention!

- mike

More information about the DB-SIG mailing list