Speed of string += string

Skip Montanaro skip at pobox.com
Sat Apr 12 19:00:21 EDT 2003


    Carl> Surprisingly, += doesn't appear to be a major time waster for
    Carl> small (meaning about 10000 bytes) strings.  I'm guessing it's
    Carl> because the malloc my system (Debian Linux) is optimized for small
    Carl> memory allocations.

Actually, if you're using 2.2.n or later, it's Python's small object
allocator (see Objects/obmalloc.c), which is providing most of the speedup.
I'm not sure if n is 0, 1, or 2.

Skip






More information about the Python-list mailing list