From: Fred Drake Date: Tue, 17 Sep 2002 18:10:34 +0000 (+0000) Subject: write(): Special case the common situation of a stream that's only X-Git-Tag: v2.3c1~4043 X-Git-Url: http://git.ipfire.org/gitweb.cgi?a=commitdiff_plain;h=d679e09970465d1b914b7d3dc11eaddbbcd6d289;p=thirdparty%2FPython%2Fcpython.git write(): Special case the common situation of a stream that's only being used to dump output (no seeks), so we can avoid a lot of extra checks being made. --- diff --git a/Lib/StringIO.py b/Lib/StringIO.py index 7c4b6c7705c7..79ab7e16b329 100644 --- a/Lib/StringIO.py +++ b/Lib/StringIO.py @@ -152,6 +152,10 @@ class StringIO: # Force s to be a string or unicode if not isinstance(s, basestring): s = str(s) + if self.pos == self.len: + self.buflist.append(s) + self.len = self.pos = self.pos + len(s) + return if self.pos > self.len: self.buflist.append('\0'*(self.pos - self.len)) self.len = self.pos