-
-
Notifications
You must be signed in to change notification settings - Fork 10.9k
BUG: fix choose refcount leak #24188
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
Changes from all commits
2f92f29
c4261af
68eead8
fd96b34
74979f3
c176234
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -10028,3 +10028,14 @@ def test_argsort_int(N, dtype): | |
arr = rnd.randint(low=minv, high=maxv, size=N, dtype=dtype) | ||
arr[N-1] = maxv | ||
assert_arg_sorted(arr, np.argsort(arr, kind='quick')) | ||
|
||
|
||
@pytest.mark.skipif(not HAS_REFCOUNT, reason="Python lacks refcounts") | ||
def test_gh_22683(): | ||
b = 777.68760986 | ||
a = np.array([b] * 10000, dtype=object) | ||
refc_start = sys.getrefcount(b) | ||
np.choose(np.zeros(10000, dtype=int), [a], out=a) | ||
np.choose(np.zeros(10000, dtype=int), [a], out=a) | ||
refc_end = sys.getrefcount(b) | ||
assert refc_end - refc_start < 10 | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. could probably go less than There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. In case you iterate: Randomly realized that this actually stopped doing anything useful on Python 3.12, because IIRC the literal 1 will be an immortal object (and thus it's reference count doesn't change reliably). |
Uh oh!
There was an error while loading. Please reload this page.