mirror of
https://github.com/python/cpython.git
synced 2025-08-03 16:39:00 +00:00
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.
This commit is contained in:
parent
c687401337
commit
d679e09970
1 changed files with 4 additions and 0 deletions
|
@ -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
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue