[Python-checkins] python/dist/src/Lib StringIO.py,1.33,1.34

rhettinger at users.sourceforge.net rhettinger at users.sourceforge.net
Mon Mar 8 13:17:33 EST 2004


Update of /cvsroot/python/python/dist/src/Lib
In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv13720/Lib

Modified Files:
	StringIO.py 
Log Message:
SF patch #907403:  Improvements to cStringIO.writelines()

The writelines() method now accepts any iterable argument and writes
the lines one at a time rather than using ''.join(lines) followed by
a single write.  Results in considerable memory savings and makes
the method suitable for use with generator expressions.



Index: StringIO.py
===================================================================
RCS file: /cvsroot/python/python/dist/src/Lib/StringIO.py,v
retrieving revision 1.33
retrieving revision 1.34
diff -C2 -d -r1.33 -r1.34
*** StringIO.py	12 Feb 2004 17:35:05 -0000	1.33
--- StringIO.py	8 Mar 2004 18:17:31 -0000	1.34
***************
*** 179,184 ****
          self.pos = newpos
  
!     def writelines(self, list):
!         self.write(''.join(list))
  
      def flush(self):
--- 179,186 ----
          self.pos = newpos
  
!     def writelines(self, iterable):
!         write = self.write
!         for line in iterable:
!             write(line)
  
      def flush(self):




More information about the Python-checkins mailing list