On Wed, 6 May 2020 at 01:41, Greg Ewing <greg.ew...@canterbury.ac.nz> wrote:
> On 6/05/20 2:22 am, jdve...@gmail.com wrote: > > However, if sets and frozensets are "are considered to be > > fundamentally the same kind of thing differentiated by mutability", > > as you said, why not tuples and lists? > > I think that can be answered by looking at the mathematical > heritage of the types involved: > > Python Mathematics > ------ ----------- > set set > frozenset set > tuple tuple > list sequence > > To a mathematician, however, tuples and sequences are very > different things. Python treating tuples as sequences is a > "practicality beats purity" kind of thing, not to be expected > from a mathematical point of view. > > I don't think that is accurate to represent as a representation of "a mathematician". The top voted answer here disagrees: https://math.stackexchange.com/questions/122595/whats-the-difference-between-tuples-and-sequences "A sequence requires each element to be of the same type. A tuple can have elements with different types." The common usage for both is: you have a tuple of (Z, +) representing the Abelian group of addition (+) on the integers (Z), whereas you have the sequence {1/n}_{n \in N} converging to 0 in the space Q^N (rational infinite sequences) for example. I'd say the difference is just one of semantics and as a mathematician I would consider tuples and sequences as "isomorphic", in fact, the set-theoretical construction of tuples as functions is *identical* to the usual definition of sequences: i.e. they are just two interpretations of the the same object depending on your point of view.
_______________________________________________ Python-ideas mailing list -- python-ideas@python.org To unsubscribe send an email to python-ideas-le...@python.org https://mail.python.org/mailman3/lists/python-ideas.python.org/ Message archived at https://mail.python.org/archives/list/python-ideas@python.org/message/A7JO3MWPYGU2OJHVMC2B55CT6UTKLQBJ/ Code of Conduct: http://python.org/psf/codeofconduct/