Skip to content

makeNdArray: return pyarray directly instead of bp::incref - #108

Merged
vincefn merged 3 commits into
diffpy:mainfrom
clemisch:fix_pyarray_ref
Aug 25, 2026
Merged

makeNdArray: return pyarray directly instead of bp::incref #108
vincefn merged 3 commits into
diffpy:mainfrom
clemisch:fix_pyarray_ref

Conversation

@clemisch

Copy link
Copy Markdown
Contributor

Backend helper makeNdArray unnecessarily uses bp::incref on returned array. This increases its refcount from 1 to 2 and effectively leads to a memory leak. PyArray_SimpleNew() already returns a new reference with refcount 1 so the incref is unnecessary.

@clemisch

clemisch commented Aug 25, 2026

Copy link
Copy Markdown
Contributor Author

PS: I know this number of incoming contributions might look a bit... suspicious these days. I have been using them for months in my forks; it's just that I finally contribute them upstream now all at once ;-)

E.g. this one is here: clemisch@0786ab5

@vincefn

vincefn commented Aug 25, 2026

Copy link
Copy Markdown
Collaborator

Can you add the corresponding news item ?

@clemisch

Copy link
Copy Markdown
Contributor Author

done

@vincefn
vincefn merged commit 3495518 into diffpy:main Aug 25, 2026
5 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.

2 participants