You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
PEP-3108 calls for StringIO (which is io.StringIO in 3.0) to have an
accelerated version behind it when available. Alexandre has been working
on this so assigning to him.
Here's a preliminary patch that add the C optimization for StringIO.
All tests are passing except two which depends on the StringIO.buffer
attribute of the TextIOWrapper class. Honestly, I am not sure what is
the correct way to fix this. I cannot simply "fake" the attribute by
returning a BytesIO object, since the file position of buffer is
undecidable. It seems to me that the only way to fix these failing tests
would be to define a FakeIO class, in their test file, that would wrap
ByteIO with TextIOWrapper, just like the old and inefficient StringIO.
So, any idea on what would be the best thing to do?
Here's another patch fixes the failing tests. I have tried to support
the buffer attribute using following hack:
@propertydefbuffer(self):
# XXX Hack to support the buffer attribute.buf=codecs.getwriter(self.encoding)(BytesIO(), self.errors)
value=self.getvalue()
buf.write(value[:self.tell()])
pos=buf.stream.tell()
buf.write(value[self.tell():])
buf.stream.seek(pos)
returnbuf.stream
but this doesn't work since some application might want to modify the
buffer. So, I removed it. Another thing that bothered me were the bogus
encoding and errors arguments. So, I also removed them.
Activity
brettcannon commentedon May 19, 2008
PEP-3108 calls for StringIO (which is io.StringIO in 3.0) to have an
accelerated version behind it when available. Alexandre has been working
on this so assigning to him.
avassalotti commentedon Jun 10, 2008
Here's a preliminary patch that add the C optimization for StringIO.
All tests are passing except two which depends on the StringIO.buffer
attribute of the TextIOWrapper class. Honestly, I am not sure what is
the correct way to fix this. I cannot simply "fake" the attribute by
returning a BytesIO object, since the file position of buffer is
undecidable. It seems to me that the only way to fix these failing tests
would be to define a FakeIO class, in their test file, that would wrap
ByteIO with TextIOWrapper, just like the old and inefficient StringIO.
So, any idea on what would be the best thing to do?
avassalotti commentedon Jun 11, 2008
Here's another patch fixes the failing tests. I have tried to support
the buffer attribute using following hack:
but this doesn't work since some application might want to modify the
buffer. So, I removed it. Another thing that bothered me were the bogus
encoding and errors arguments. So, I also removed them.
avassalotti commentedon Jun 11, 2008
I updated the patch to use the new module framework.
avassalotti commentedon Jun 11, 2008
Committed in r64154.