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

BUG: fix a numpy.npiter leak in npyiter_multi_index_set #19500

Merged
merged 3 commits into from Jul 17, 2021

Conversation

charris
Copy link
Member

@charris charris commented Jul 16, 2021

Backport of #19396.

Resolves #19375.

Moves the Py_DECREF call one line before, so the reference count will be always decresed.

Example

import sys

import numpy as np

index = 0
it = np.nditer(np.array([43124, 1234, 123432, 123432]), flags=['multi_index'])

print(sys.getrefcount(index))

for i in range(200):
    it.multi_index = (index,)

print(sys.getrefcount(index))

Before this PR

1962
2162

After this PR

1403
1403

Note: this is my first PR on this repository and my second one in my life, tell me if you have any feedback.

@charris charris added 00 - Bug 08 - Backport Used to tag backport PRs labels Jul 16, 2021
@charris charris added this to the 1.21.1 release milestone Jul 16, 2021
@charris charris merged commit 74f82c9 into numpy:maintenance/1.21.x Jul 17, 2021
@charris charris deleted the backport-19396 branch July 17, 2021 00:25
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
00 - Bug 08 - Backport Used to tag backport PRs
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants