diff options
author | Fred Drake <fdrake@acm.org> | 2002-09-17 18:10:34 (GMT) |
---|---|---|
committer | Fred Drake <fdrake@acm.org> | 2002-09-17 18:10:34 (GMT) |
commit | d679e09970465d1b914b7d3dc11eaddbbcd6d289 (patch) | |
tree | 94660d705388b809753874fde618796cf5fbe0db /Lib | |
parent | c6874013379f22cbcde563f7e8c24ae6ba1bc305 (diff) | |
download | cpython-d679e09970465d1b914b7d3dc11eaddbbcd6d289.zip cpython-d679e09970465d1b914b7d3dc11eaddbbcd6d289.tar.gz cpython-d679e09970465d1b914b7d3dc11eaddbbcd6d289.tar.bz2 |
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.
Diffstat (limited to 'Lib')
-rw-r--r-- | Lib/StringIO.py | 4 |
1 files changed, 4 insertions, 0 deletions
diff --git a/Lib/StringIO.py b/Lib/StringIO.py index 7c4b6c7..79ab7e1 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 |