Skip to content

TST. API: test using distributions.h via cffi #14954

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

Merged
merged 4 commits into from
Nov 27, 2019

Conversation

mattip
Copy link
Member

@mattip mattip commented Nov 21, 2019

xref #14951

Add an example of calling functions from distributions.h from cffi

@mattip
Copy link
Member Author

mattip commented Nov 22, 2019

I also made sure the numba test passes locally on windows. Numba is a bit heavy and moving too fast to be a permanent test dependency. I don't think they have released a Python3.8 version yet.

@mattip
Copy link
Member Author

mattip commented Nov 22, 2019

The test failure seems unrelated - matmul is seeing an invalid value on win32. I think this is a different manifestation of the occasional heisenbug.

@bashtage
Copy link
Contributor

A very heavy handed approach to make these available for Cython through _generator. binary would be to use wrap the functions and use the api flag for Cython. Probably a non-starter, but I foudn this when looking for a solution.

@mattip
Copy link
Member Author

mattip commented Nov 22, 2019

The solutions I see in the cython documentation do seem rather heavy-handed. We expose the functions from python, but as you say that requires the Python->C-API->call the function->C-API->Python route. Maybe we should delay extending the API for now?

@bashtage
Copy link
Contributor

It looks like the only "easy" and universal method is to compile the functions into distributions.lib or libdistributions.so like npymath.lib. This would allow downstream Cython to link to these functions, and if they want to use Numba, a downstream could create a dll from the subset of the lib they need.

Of course, not really easy.

@bashtage
Copy link
Contributor

Or ship numpy/random/scr/distributions/distributions.c

@mattip
Copy link
Member Author

mattip commented Nov 22, 2019

Let's continue the discussion about extending for cython on gh-14778

@mattip
Copy link
Member Author

mattip commented Nov 22, 2019

Tests pass, documentation added here and here. Is there anything more needed to demonstrate this example?

@bashtage
Copy link
Contributor

I think this proves teh case for cffi.

@charris charris added this to the 1.18.0 release milestone Nov 25, 2019
@charris charris merged commit 3fcf144 into numpy:master Nov 27, 2019
@charris
Copy link
Member

charris commented Nov 27, 2019

Thanks Matti.

@mattip mattip deleted the test-extending-cffi branch November 2, 2020 08:29
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants