[Python-Dev] Usage of += on strings in loops in stdlib
MRAB
python at mrabarnett.plus.com
Wed Feb 13 00:20:01 CET 2013
More information about the Python-Dev mailing list
Wed Feb 13 00:20:01 CET 2013
- Previous message: [Python-Dev] Usage of += on strings in loops in stdlib
- Next message: [Python-Dev] Usage of += on strings in loops in stdlib
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]
On 2013-02-12 21:44, Antoine Pitrou wrote: > On Tue, 12 Feb 2013 16:40:38 -0500 > Ned Batchelder <ned at nedbatchelder.com> wrote: >> >> But the only reason "".join() is a Python idiom in the first place is >> because it was "the fast way" to do what everyone initially coded as "s >> += ...". Just because we all learned a long time ago that joining was >> the fast way to build a string doesn't mean that "".join() is the clean >> idiomatic way to do it. > > It's idiomatic because strings are immutable (by design, not because of > an optimization detail) and therefore concatenation *has* to imply > building a new string from scratch. > Tuples are much like immutable lists; sets were added, and then frozensets; should we be adding mutable strings too (a bit like C#'s StringBuilder)? (Just wondering...)
- Previous message: [Python-Dev] Usage of += on strings in loops in stdlib
- Next message: [Python-Dev] Usage of += on strings in loops in stdlib
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]
More information about the Python-Dev mailing list