Add implementation using Numpy C UFunc API#3
Conversation
|
Nice! I agree that we should centralize the test suite and also probably do some speed benchmarks. |
c_ufunc/setup.py
Outdated
There was a problem hiding this comment.
Minor: I think this is missing the numpy include path?
|
@mdboom - could you show a usage example? At the moment: Am I using it wrong? |
|
@astrofrog: I see that too. I did this kind of hastily, and I think I may have messed something up... Stay tuned... |
|
I'm running into the same problem here -- there doesn't seem to be a way to have ufuncs over string fields. Looking at the code, it seems there used to be a way but it got sort of papered over over time 😦 As discussed in #1, though, that parameter doesn't need to be vectorized, so we can wrap this in another function that just takes it as a scalar. That's where things start to get a little hairy, of course. |
|
I think #1 is already to be considered generally superior to this. It seems the UFunc API just isn't flexible enough for our needs -- I was hoping it would be a win since it handles the broadcasting etc. for us. It may make sense to do a C implementation of #1 for comparison at some point, but I think I've convinced myself that the UFunc API is insufficient. |
For now, the tests from #1 can be used with this extension module -- but I think eventually we want to centralize the test suite and have it run against all of the implementations as a fixture.
Just to compare and contrast with #1: By using the UFunc API, this lets Numpy handle the broadcasting for us upfront, rather than handling it ourselves. I think the per-erfa-function lines-of-code is probably a little lower for this approach as well (though there is some extra helper functions at the top, we only have to get that right once).