Skip to content

Conversation

miss-islington
Copy link
Contributor

@miss-islington miss-islington commented Sep 11, 2024

Now a memoryview object can only be cleared if there are no buffers
that refer it.
(cherry picked from commit a1dbf2e)

Co-authored-by: Serhiy Storchaka storchaka@gmail.com

…moryview (pythonGH-123898)

Now a memoryview object can only be cleared if there are no buffers
that refer it.
(cherry picked from commit a1dbf2e)

Co-authored-by: Serhiy Storchaka <storchaka@gmail.com>
return 0;
self->flags |= _Py_MEMORYVIEW_RELEASED;
assert(self->mbuf->exports > 0);
if (--self->mbuf->exports == 0) {
Copy link
Contributor

Choose a reason for hiding this comment

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

Maybe changing if (--self->mbuf->exports == 0) to

self->mbuf->exports -= 1; // or self->mbuf->exports--;
if (self->mbuf->exports == 0)
...

will be more readable, that my idea.

Copy link
Contributor

Choose a reason for hiding this comment

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

I personally think that --self->mbuf->exports is a bit confusing.

Copy link
Member

Choose a reason for hiding this comment

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

This was in the old code.

If you want to change this code, create a PR for the main branch. The backported code should not differ from the original code without good reasons.

return 0;
self->flags |= _Py_MEMORYVIEW_RELEASED;
assert(self->mbuf->exports > 0);
if (--self->mbuf->exports == 0) {
Copy link
Member

Choose a reason for hiding this comment

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

This was in the old code.

If you want to change this code, create a PR for the main branch. The backported code should not differ from the original code without good reasons.

@Yhg1s Yhg1s merged commit 4c3d537 into python:3.13 Sep 30, 2024
39 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants