-
-
Notifications
You must be signed in to change notification settings - Fork 30k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Fast BytesIO implementation + misc changes #46091
Comments
Finally, here is my C implementation of BytesIO. The code is well tested
Currently, I have no idea how to fix the tests for the profilers. The % ./python Lib/test/regrtest.py -R: test_profile |
Any chance of uploading a single patch that contains all these changes? The profile tests often fail when io.py changes because they happen to |
So, here's one big patch. I have updated the behavior of close(), so that
Yes, I knew that. But, how can I fix the test so that it passes even if Oh, one more thing. In the misc fixes for io.py, I added a checkClosed >>> f = open("load.py")
[45681 refs]
>>> next(f)
'import sys\n'
[45700 refs]
>>> f.close()
[45703 refs]
>>> next(f)
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
File "/home/alex/src/python.org/py3k/Lib/io.py", line 1440, in __next__
line = self.readline()
File "/home/alex/src/python.org/py3k/Lib/io.py", line 1449, in readline
raise ValueError("read from closed file")
ValueError: read from closed file
[45703 refs] |
[grrr, I eat my words]
... it matches the behavior of 2.x.
... when the file is closed. |
I got a patch that also fixes the profiler tests. That was easy after |
Here is a patch against the latest trunk (r61578) that includes the |
Bumping priority so that this gets reviewed before next release. |
From a quick glance: I may be wrong, but it looks like in |
Yes, that was a leak. It should be fixed now. Merci Antoine! |
Alexandre, is it normal that the unit tests look much less complete in |
Oops, I forgot to include the unit tests, with "svn add", when I made |
There is a small bug in the last patch I posted. The unit tests assumed |
Ok I took a detailed look at _bytesio.c. In write_bytes() there is the following resizing logic: if (self->pos + len > self->string_size) {
if (resize_buffer(self, self->pos + len) < 0)
return -1;
} Replacing For some reason, using the help() function on a BytesIO instance does Overall, the new module looks fine. I can't say anything about the io.py |
One last thing: you probably noticed it, but there is one test which |
I think that check in write_bytes() is a guard to avoid resize_buffer() I don't know why help() doesn't work on BytesIO instances. But, the Finally regarding test_StringIO, see msg59460. Anyway, test_StringIO is |
Well, by construction self->buf_size should always be greater than |
I'm going to review the patch later. How are we going to back port the |
Hey Alexandre! The latest patch doesn't apply cleanly. Please provide a new patch. |
Here's an updated patch. |
Oops, I forgot again to "svn add" the new files. |
Do I need to look at this, or is the review going well without my |
Hi Guido, The patch changes a minor things to io.py to allow io.BytesIO to pass my |
Since nothing happened for almost one month here, perhaps it would be It would also allow to progress on other issues, e.g. bpo-2523. Also, I stand by the suggestion I made about the resizing logic, but it |
Alexandre, you have until the end of the week to commit it or someone else |
By the way, is someone already working on a C-accelerated TextIO? |
Patch committed in r62778. Antoine wrote:
I made your suggested change to the resizing logic. Thanks again for the
Yes. I was waiting to commit the C optimization for io.BytesIO, before |
Note: these values reflect the state of the issue at the time it was migrated and might not reflect the current state.
Show more details
GitHub fields:
bugs.python.org fields:
The text was updated successfully, but these errors were encountered: