[Python-Dev] Wild Idea for the Year

Josiah Carlson jcarlson at uci.edu
Thu Jun 24 04:34:50 EDT 2004


> What is wrong with the following code?
> 
>     def join(*iterable):
>         s = ""
>         for e in iterable:
>             s = s + e
>         return s

[snip implementation specific description]

That would be terribly nifty, but it begs the question:
If we do this for strings (an immutable sequence type), do we do this
for tuples (another immutable sequence type)?

Likely not on the tuple side, considering Python's reliance on tuples in
virtually every (is it every?) function call, additional overhead is
additional overhead, and rarely do I see people doing tuple
concatenation.

I do like the possibility that Python can be the first language to solve
the repeated string concatenation problem.  It would also reduce the
need to tell newbies in c.l.py "don't do string concatenation, use
''.join(lst)".

 - Josiah




More information about the Python-Dev mailing list