[Python-Dev] Re: PEP 292 - Simpler String Substitutions
Nick Coghlan
ncoghlan at iinet.net.au
Wed Aug 25 00:20:39 CEST 2004
M.-A. Lemburg wrote:
> ncoghlan at iinet.net.au wrote:
>
>> pass (essentially, all of the work done so far is thrown away, and the
>> Unicode
>> join starts from scratch. If you know you have Unicode, you're better
>> off using
>> a Unicode separator to avoid this unnecessary work </tangent>).
>
>
> It's just a simple length querying loop; there's no storage allocation
> or anything expensive happening there, so the "throw-away" operation
> is not expensive.
Yes, my mistake. The tuple that string join creates when the argument is
an iterable rather than a list or tuple isn't thrown away - it is given
to PyUnicode_Join to work with (since the original iterator may not be
able to be iterated a second time).
The only work that is lost is that all of the type checks that have been
done on prior elements will get repeated in the Unicode join code. So
it's not as bad as I first thought - but it will still cost a few cycles.
Regards,
Nick.
More information about the Python-Dev
mailing list