Repository navigation
Conversation
|
There seems to be a major code redundancy with I admit that the name isn't ideal then... |
|
@scoder I feel your pain but 53 lines is hardly a major code redundancy and it looked pretty ugly to handle differing behaviors inside inline. I considered making them one, as a matter of fact I really just started with inline but it wasn't worth it to me. I think inline could actually now be based on inline_module... but that's a 2nd optional pass and leaves a question of how to handle the signatures inline presently extracts from arguments. Maybe the hash should be on the result pxd file and not the input? Handling all the argument behavior variations in cython_inline will make up the difference and make the functions as not simple/not straightforward/fragile. inline expects to work with arguments immediately and does lots of inspection on them, module_inline is strictly just for quasi-JIT/AOC without bringing in the arguments yet. I really wanted to use compile instead but it's already taken and honestly I think what it is doing now is stupid and should be replaced with module_inline's implementation - the behavior given to it now is different though and also works with arguments/slow on reuse due to repeated calls to cython_inline - see RuntimeCompiledFunction for what I'm talking about - it only offers half the utility such a function should have, in terms of the libraries promise of performance. |
| if force or not os.path.isfile(module_path): | ||
| qualified = re.compile(r'([.\w]+)[.]') | ||
| #assume everybody wants numpy | ||
| if include_numpy: |
There was a problem hiding this comment.
Couldn't this be automatically detected?
|
I find 53 lines to be significant redundancy. I agree that it makes more sense for the current inline could be based on module_inline (or a shared function that encapsulates the core functionality from the two different interfaces). |
|
In that case, I think you should just break API on compile, renaming module_inline. I'm not really sure how the signatures matter to the compilation key/file but if you remove them, then inline will have no problem using compile/module_inline. |
|
@nevion Thank you very much for your work. I refactored it as was requested above in #3145. I was sorely missing this functionality...
I fixed the code duplication with refactoring. As @nevion already mentioned, it was far from simple and is not all that pretty. This however cannot be avoided IMHO due to the logic flow of I did implement your suggestion of "scope='module'" argument for In analogy to current behaviour, users would expect the following to be possible: That will however fail:
Let me know if you agree with my reasoning.
I took your suggestion and implemented a "bare bones" interface that does the minimal amount of code processing to allow users the flexibility to implement custom variations without having to copy the entire core functionality. |
|
sounds good, hope this next pass makes it in |
|
Following +1 for something like this to be added into cython to be able to dynamically compile/cythonize some python code. Thanks! |
allows JIT/slightly AOC module compilation, similar to that of OpenCL/PyCUDA/PyOpenCL.
This is useful for maximum performance with simpler reusable modules and simplifies flow code-fragment acceleration. The intent is to compile a (C/C++) module in initialization when all algorithm details are known (say those dependent on configuration or input data) - then put it in immediate high-performance use.
It is based off the cython.inline implementation.