Visitar URL original
bpo-35210: Use bytes + memoryview + resize instead of bytesarray + array in io.RawIOBase.read by tzickel · Pull Request #10451 · python/cpython · GitHub
The Wayback Machine - https://web.archive.org/web/20221223141336/https://github.com/python/cpython/pull/10451
Skip to content
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

bpo-35210: Use bytes + memoryview + resize instead of bytesarray + array in io.RawIOBase.read #10451

Closed
wants to merge 1 commit into from

Conversation

tzickel
Copy link
Contributor

@tzickel tzickel commented Nov 10, 2018 •

@@ -0,0 +1,2 @@
Use bytes + memoryview + resize instead of bytesarray + bytes in
io.RawIOBase.read
Copy link
Contributor

@ZackerySpytz ZackerySpytz May 29, 2020

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
io.RawIOBase.read
:meth:`io.RawIOBase.read`.

I think this news entry is a little too vague.

if (newn < n) {
if (refcnt == 1) {
_PyBytes_Resize(&b, newn);
} else {
Copy link
Contributor

@ZackerySpytz ZackerySpytz May 29, 2020

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

According to PEP 7, the } should be by itself on the previous line (https://www.python.org/dev/peps/pep-0007/#code-lay-out).

Suggested change
} else {
}
else {

} else if (newn == n) {
return b;
} else {
PyErr_SetString(PyExc_RuntimeError, "readinto() returned bad value");
Copy link
Contributor

@ZackerySpytz ZackerySpytz May 29, 2020

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I don't think RuntimeError should be used here.

@@ -898,36 +898,58 @@ static PyObject *
_io__RawIOBase_read_impl(PyObject *self, Py_ssize_t n)
/*[clinic end generated code: output=6cdeb731e3c9f13c input=b6d0dcf6417d1374]*/
{
PyObject *b, *res;
PyObject *b, *res, *mem;
Py_ssize_t newn, refcnt;
Copy link
Contributor

@ZackerySpytz ZackerySpytz May 29, 2020

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

These new variables don't need to be declared at the top of the block.

@iritkatriel
Copy link
Member

iritkatriel commented Sep 9, 2022

@tzickel Are you still working on this?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

6 participants