GeezerVisonThe World Wide Web, restored to 800 pixels of glory. | ||||||||||||||||||||||||||||||||
| Home|About|Gaming cabinet|Archives|How it works|Starter sites | ||||||||||||||||||||||||||||||||
GeezerVison is showing github.com — gh-150942: Speed up IOBase.readlines by demitryfly · Pull Request #155304 · python/cpython Conversation
| ||||||||||||||||||||||||||||||||
|
Most changes to Python require a NEWS entry. Add one using the blurb_it web app or the blurb command-line tool. If this change has little impact on Python users, wait for a maintainer to apply the |
Sorry, something went wrong.
There was an error while loading. Please reload this page.
f2b4ed4 to
c75bcab
Compare
|
|
||
| if (PyList_Append(result, line) < 0) { | ||
| Py_DECREF(line); | ||
| if (_PyList_AppendTakeRef((PyListObject *)result, line) < 0) { |
There was a problem hiding this comment.
The reason will be displayed to describe this comment to others. Learn more.
The call to PyObject_Size(line) should be moved up. After the _PyList_AppendTakeRef we are no longer have a valid reference to line.
Sorry, something went wrong.
There was an error while loading. Please reload this page.
| /* XXX special-casing this made sense in the Python version in order | ||
| to remove the bytecode interpretation overhead, but it could | ||
| probably be removed here. */ | ||
| PyObject *ret = PyObject_CallMethodObjArgs(result, &_Py_ID(extend), |
There was a problem hiding this comment.
The reason will be displayed to describe this comment to others. Learn more.
The changes in this PR will not matter for calls like f.readlines() since that ends up in the fast path here. We could change the call here to PyObject_CallMethodOneArg which might be faster, but that is for another PR.
Sorry, something went wrong.
There was an error while loading. Please reload this page.
| @@ -0,0 +1,2 @@ | |||
| Improve the performance of :meth:`io.IOBase.readlines` by avoiding | |||
There was a problem hiding this comment.
The reason will be displayed to describe this comment to others. Learn more.
Can you provide benchmarks where this change has a positive effect for real-world cases? I suspect the change might be too minimal to warrant acceptance of the PR.
Sorry, something went wrong.
There was an error while loading. Please reload this page.
There was a problem hiding this comment.
The reason will be displayed to describe this comment to others. Learn more.
The benchmark showed that this change has no significant effect, so I’ve decided to close this PR.
Thanks for the review!
Sorry, something went wrong.
There was an error while loading. Please reload this page.
There was an error while loading. Please reload this page.
Successfully merging this pull request may close these issues.
There was an error while loading. Please reload this page.