[Python-Dev] Usage of += on strings in loops in stdlib

Serhiy Storchaka storchaka at gmail.com
Wed Feb 13 12:28:32 CET 2013


On 12.02.13 23:03, Maciej Fijalkowski wrote:
> How people feel about generally not having += on long strings in
> stdlib (since the refcount = 1 thing is a hack)?

Sometimes the use of += for strings or bytes is appropriate. For 
example, I deliberately used += for bytes instead b''.join() (note that 
there is even no such hack for bytes) in zipfile module where in most 
cases one of component is empty, and the concatenation of nonempty 
components only happens once. b''.join() was noticeably slower here.



More information about the Python-Dev mailing list