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

Pure Python first pass? #2089

Open
Dapid opened this issue Mar 16, 2023 · 1 comment
Open

Pure Python first pass? #2089

Dapid opened this issue Mar 16, 2023 · 1 comment

Comments

@Dapid
Copy link
Contributor

Dapid commented Mar 16, 2023

Sometimes I find a small function missing from Pythran. Implementing it in C++ may be a little bit challenging, but I can often bypass it by copying the source code into my own function.

For example np.fft.fftshift is missing from Pythran, but it is a simple wrapper around np.roll, so simply dropping the definition in my code works:

def fftshift(x):
    shift = x.shape[0] // 2
    return np.roll(x, shift, 0)

[Caveat]

Would it be possible to have Pythran read from a library of Python code? So, if I use np.fft.fftshift, the first pass would translate to the previous function (vendored in Pythran), and the second pass would generate the C++ code. This makes adding more functions and plugging gaps much easier, since it doesn't require to write C++.

@serge-sans-paille
Copy link
Owner

I like that idea. It would make contributions easier, and would pave the way for external library support.

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

No branches or pull requests

2 participants