[Python-Dev] Re: PEP 292 - Simpler String Substitutions (original) (raw)

Tim Peters tim.peters at gmail.com
Tue Aug 24 18:43:11 CEST 2004


[M.-A. Lemburg]

... Aside: ''.join() currently only works for true sequences - not iterators.

def gen(): ... for s in "sure", "it", "does": ... yield s ... ' '.join(gen()) 'sure it does' u' '.join(gen()) u'sure it does'

Every function implemented with PySequence_Fast() works with any iterable, although it's fastest if the input argument is a builtin list or tuple. For anything else (including list or tuple subclasses, and other "true sequences"), it materializes a temp tuple, via the iterator protocol.



More information about the Python-Dev mailing list