String.join revisited (URGENT for 1.6)

Fredrik Lundh effbot at telia.com
Mon May 29 08:42:21 CEST 2000


Eric Jacobs wrote:
> Doesn't seem like it would have to. Just imagine a method in the sequence
> "class" that said:
> 
>      def join(self, separator):
>          result = self[0]
>          for x in self[1:]:
>              result = result + separator + x
>          return result
> 
> No new operators are necessary, unless you want join to do something
> completely different...

like, for example, joining strings efficiently?

(If you don't see my point, try benchmarking your code vs. string.join
on 10, 1000, 100000 substrings. Do you think the timing difference can
be eliminated by writing your code in C?)

</F>




More information about the Python-list mailing list