Skip to content

Use NumPy C api to perform conversion to ArrayLike#542

Merged
Icxolu merged 3 commits intoPyO3:mainfrom
mattiapenati:better-usage-of-c-api
Mar 29, 2026
Merged

Use NumPy C api to perform conversion to ArrayLike#542
Icxolu merged 3 commits intoPyO3:mainfrom
mattiapenati:better-usage-of-c-api

Conversation

@mattiapenati
Copy link
Copy Markdown
Contributor

In this PR, the NumPy C API is used to convert from a Python object to ArrayLike. The previous implementation was based on the numpy.asarray function, this new implementation avoids passing through the interpreter to convert data.

The new implementation has been benchmarked and shows no regressions. It is likely slightly faster, though the difference is hard to measure precisely.

Benchmarks have been ported to criterion to remove the dependency on the Rust nightly version.

Copy link
Copy Markdown
Member

@Icxolu Icxolu left a comment

Choose a reason for hiding this comment

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

Thank you, I have found I problem, otherwise looks good to me.

@mattiapenati mattiapenati force-pushed the better-usage-of-c-api branch from fd3a63d to e5d79d5 Compare March 29, 2026 17:04
@Icxolu Icxolu merged commit 3c382b3 into PyO3:main Mar 29, 2026
76 checks passed
@mattiapenati mattiapenati deleted the better-usage-of-c-api branch March 29, 2026 18:19
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