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

Do not cache import of numpy in C++ #3105

Merged
merged 2 commits into from Mar 31, 2023
Merged

Do not cache import of numpy in C++ #3105

merged 2 commits into from Mar 31, 2023

Conversation

jl-wynen
Copy link
Member

The old code triggered a segfault in ScippNeXus with Python 3.10. I don't know exactly why, this is hard to reproduce. But I suspect it has to do with the tear down order. Numpy might be deallocated before scipp which creates a dangling reference with the static variable.

I benchmarked this and got

old: 0.008s
new: 0.011s

with

import scipp as sc
from timeit import repeat
ts = repeat("var.value",
            setup="var=sc.scalar(123)",
            globals={"sc": sc},
            number=10_000,
            repeat=1_000)
print(min(ts))

@jl-wynen jl-wynen merged commit 457abf4 into main Mar 31, 2023
4 checks passed
@jl-wynen jl-wynen deleted the dont-cache-numpy-import branch March 31, 2023 12:29
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.

None yet

2 participants