[Patches] [ python-Patches-907403 ] Improvements to
cStringIO.writelines()
SourceForge.net
noreply at sourceforge.net
Sun Mar 7 22:25:22 EST 2004
Patches item #907403, was opened at 2004-03-01 04:35
Message generated for change (Comment added) made by nnorwitz
You can respond by visiting:
https://sourceforge.net/tracker/?func=detail&atid=305470&aid=907403&group_id=5470
Category: Modules
Group: Python 2.4
Status: Open
>Resolution: Accepted
Priority: 5
Submitted By: Raymond Hettinger (rhettinger)
>Assigned to: Raymond Hettinger (rhettinger)
Summary: Improvements to cStringIO.writelines()
Initial Comment:
Currently, cStringIO.writelines() only accepts a
sequence argument and it passes that argument
internally to str.join() to construct a large temporary
string before writing.
The patch allows the method to accept any iterable
argument and for the lines to be written one at a time
which cuts memory utilization in half.
The result is especially valuable when used with
generators or itertools because the strings are
constructed on the fly rather than all at once.
----------------------------------------------------------------------
>Comment By: Neal Norwitz (nnorwitz)
Date: 2004-03-07 22:25
Message:
Logged In: YES
user_id=33168
I don't see any problems with the new code. One nit though,
I hate using l as a variable name because it's difficult to
tell if it's an l (ell) or a 1 (one). I realize O_cwrite
uses l. I'm not against n though. :-)
Should the docstring be updated? It says the parameter is a
sequence_of_strings. I'm not sure if it would be good to call
it an iterable_of_strings. That sounds funny.
I think it's good that it takes an iterable. That makes it
more like
StringIO.
Should StringIO.writelines() be changed? It currently does:
self.write(''.join(list))
----------------------------------------------------------------------
You can respond by visiting:
https://sourceforge.net/tracker/?func=detail&atid=305470&aid=907403&group_id=5470
More information about the Patches
mailing list