-
-
Notifications
You must be signed in to change notification settings - Fork 404
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
Re-implement binary_search in C #129
Conversation
@orbitfold great! (I'm CCing @ssim and @mklauser here). I think there are a couple of issues we should find a work around: how do we raise an exception in a C-function? Maybe stackoverflow can help with this. I think for this we can use a little tool called airspeed velocity |
ah, and Travis fails, before we could merge this, we would need to change the testing. If you have any questions about the pytest framework let me know. |
http://docs.cython.org/src/userguide/wrapping_CPlusPlus.html Apparently you can do it in C++ easily, it can catch C++ exceptions and propagate them to Python. There is even this handy table:
http://docs.cython.org/src/userguide/language_basics.html#error-return-values In C it is possible this way
So whenever the C function returns -1 it will raise a Python exception, apparently. I cannot test this right now though. |
I don't know what the best way forward is. I think sticking with C for now seems logical, but can be convinced otherwise. That means that we could use the |
Well C++ is (in theory) a superset of C, you can write C code and use C++ features as needed... |
Hmm..
compiles and installs fine, while
fails with
|
Finally passed the build and tests! |
@orbitfold great work. We should merge this as soon as we have asv running - this way we can see if there was any speedup. |
Unless there is something I missed I think this can be merged in. |
@orbitfold @wkerzendorf This looks good to me. I will merge it now (and add a line to the change log). |
Here is how I would do it. It works. However there I don't know of a way to raise a Python exception from a pure C function. I can trying doing the others too and C if some kind of speed-up can be achieved.
Please feel free to reject this pull request this is just a proof of concept.