Skip to content

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

Merged
charris merged 4 commits into
numpy:masterfrom
mattip:test-extending-cffi
Nov 27, 2019
Merged

charris merged 4 commits into
numpy:masterfrom
mattip:test-extending-cffi

Conversation

@mattip

@mattip mattip commented Nov 21, 2019

Copy link
Copy Markdown
Member

xref #14951

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

@mattip

mattip commented Nov 22, 2019

Copy link
Copy Markdown
Member Author

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

mattip commented Nov 22, 2019

Copy link
Copy Markdown
Member Author

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
Copy Markdown
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

mattip commented Nov 22, 2019

Copy link
Copy Markdown
Member Author

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
Copy Markdown
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
Copy Markdown
Contributor

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

@mattip

mattip commented Nov 22, 2019

Copy link
Copy Markdown
Member Author

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

@mattip

mattip commented Nov 22, 2019 •

Copy link
Copy Markdown
Member Author

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

@bashtage

Copy link
Copy Markdown
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

charris commented Nov 27, 2019

Copy link
Copy Markdown
Member

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