Serhiy Storchaka added the comment: In a normal loop we copy into the output buffer for each iteration the element and the separator. As you know, the processor can copy large amounts of data several times more efficiently than byte-for-byte. Therefore, filling the buffer by memset more efficient than calling Py_MEMCPY on each iteration if the buffer size is not too large. Experimenting on different machines I found that Py_MEMCPY is more expensive than sequential filling up to 32 bytes (may be even more, but I chose a conservative estimate). And for empty separator we can just omit copying and filling (it saves several checks per iteration).
---------- versions: +Python 3.4 -Python 3.3 _______________________________________ Python tracker <rep...@bugs.python.org> <http://bugs.python.org/issue12805> _______________________________________ _______________________________________________ Python-bugs-list mailing list Unsubscribe: http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com