Mercurial > cpython-lru_cache-weakref
diff Lib/StringIO.py @ 25305:0399c8aea7b2 legacy-trunk
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.
| author | Fred Drake <fdrake@acm.org> |
|---|---|
| date | Tue, 17 Sep 2002 18:10:34 +0000 |
| parents | e1e90b0f1f45 |
| children | 31807880f599 |
line wrap: on
line diff
--- a/Lib/StringIO.py Tue Sep 17 15:19:12 2002 +0000 +++ b/Lib/StringIO.py Tue Sep 17 18:10:34 2002 +0000 @@ -152,6 +152,10 @@ # 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
