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

Intoroduce PyComplex #226

Merged
merged 4 commits into from
Sep 21, 2018
Merged

Intoroduce PyComplex #226

merged 4 commits into from
Sep 21, 2018

Conversation

kngwyu
Copy link
Member

@kngwyu kngwyu commented Sep 20, 2018

For #224.
Now I implemented just 3 APIs for it, from_doubles, real, imag.
Some questions:

  • We should implement FromPyObject to num-complex? Since num-complex is very portable crate, I think it's good.
  • We should implement bindings for other APIs exposed when #[cfg(not(Py_LIMITED_API)]? Pesonally, I don't feel them so useful. Part of them are
PyAPI_FUNC(Py_complex) _Py_c_sum(Py_complex, Py_complex);
PyAPI_FUNC(Py_complex) _Py_c_diff(Py_complex, Py_complex);
PyAPI_FUNC(Py_complex) _Py_c_neg(Py_complex);
PyAPI_FUNC(Py_complex) _Py_c_prod(Py_complex, Py_complex);
PyAPI_FUNC(Py_complex) _Py_c_quot(Py_complex, Py_complex);
PyAPI_FUNC(Py_complex) _Py_c_pow(Py_complex, Py_complex);
PyAPI_FUNC(double) _Py_c_abs(Py_complex);

(https://github.com/python/cpython/blob/master/Include/complexobject.h), but we can do these operations in Rust side.

@konstin
Copy link
Member

konstin commented Sep 20, 2018

num-complex sounds like a good idea. I'd put it behind an off-by-default feature flag and mention it in the readme.

I think those functions should also be wrapped in rust. If we implement them using the Add, Sub, etc. traits we can use the normal +, -, etc. on PyComplex, which would be pretty neat.

Otherwise it's looking good!

@kngwyu
Copy link
Member Author

kngwyu commented Sep 21, 2018

Now ready to review 🙂

@konstin
Copy link
Member

konstin commented Sep 21, 2018

Thank you, this looks great!

Your contributions have all been really good, so I've given you commit access ✨

@konstin konstin merged commit 0dc697f into PyO3:master Sep 21, 2018
@kngwyu kngwyu deleted the complex branch September 22, 2018 02:00
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