[Python-Dev] re: syntax - "Aren't tuples redundant?"

Jean-Claude Wippler jcw@equi4.com
Fri, 04 Feb 2000 15:02:19 +0100


gvwilson@nevex.com wrote:
> 
> (Hope no-one minds me keeping this thread alive [...])

Ditto.

GV> Show them [1, "two"] and they (a) understand it, and (b) think
GV> it's cool; show them (1, "two") as well and they become confused.

Because they mean the same thing, I suppose?
 
GV> If tuples didn't already exist, would anyone ask for them to
GV> to be added to the language today?

Why indeed?  They are more space-efficient, and they are immutable, but
those are both purely technical reasons.  The first reason is likely to
become less important (silicon gets faster), the second one *could* be
solved by forcing keys to have a refcount of 1 - this means copying when
needed, both on creation and on access.  That's pretty awkward, copy on
write would help a lot, but I doubt that Python can be made to do that
(tuples neatly prevent circular immutable structures, btw).

GV> I've never had any trouble explaining int vs. float to students at

Because ints and floats differ in meaning?

GV> any level; I've also never had any trouble explaining int vs. long
GV> (memory vs. accuracy).

That's interesting.  Tuples vs. lists are a similar tradeoff, though
both memory-savings and immutability are CS-type issues, whereas non-
programmers are more likely to consider accuracy a meaningful tradeoff?

-- Jean-Claude