[Python-Dev] Re: Optional separatorargument for file.writelines()and StringIO.writelines()

Bob Ippolito bob at redivi.com
Fri Feb 27 04:30:33 EST 2004


On Feb 27, 2004, at 4:12 AM, Raymond Hettinger wrote:

> [Bob Ippolito]
>> Currently, it seems that ''.join is faster than cStringIO.writelines
>> anyway, even if you just pass it a big list.
>
> I suspect something wrong with your timing suite.  Under the hood,
> cStringIO.writelines() actually is ''.join().  It appears that the
> whole comparison is circular.

Circular in that "ends up doing approximately the same thing but has a 
lot more overhead" kind of way ;)...  I think the difference is easily 
explained by:
* N calls to join2
* N StringIO()
* N StringIO.writelines
* N StringIO.getvalue
* N StringIO dealloc
* [ probably also memcpy's 2 or 3 times as much ]

-bob
-------------- next part --------------
A non-text attachment was scrubbed...
Name: smime.p7s
Type: application/pkcs7-signature
Size: 2357 bytes
Desc: not available
Url : http://mail.python.org/pipermail/python-dev/attachments/20040227/2f05c7b9/smime-0001.bin


More information about the Python-Dev mailing list