Open cswiercz opened 8 years ago
I am in favor of the current Python wrapper signature (the "Pythonic" version, which follows the "idiomatic" Python style guide).
Okay. Thanks for the feedback. I think we'll have plenty of time in class to explain the wrapper or, at least, a very simple version of the wrapper.
The way that you've written it makes the most sense to me. My philosophy regarding foreign function interfaces is that you always want to "hide" language-specific details in a low layer as close to the foreign call as possible, whenever you can get away with it. So I think it sets a better example to write the function so that it has a Pythonic interface.
I agree with the "hiding" philosophy from a true software development perspective. My main concern is whether it would be confusing to the student. As long as I explain it thoroughly there shouldn't be a problem.
What I haven’t decided on is whether the Python wrappers should adhere to the same format as the corresponding C library functions or if they should be more “Pythonic” for example, the C library version of
vec_add
has the signaturewhereas I've written the Python wrapper
homework2.vec_add
to have the signatureThe wrapper hides the fact that memory is being edited in-place. The current definition, in fact, creates an empty solution array which is then "passed" to the underlying C function.
Would it be clearer / better to have the Python wrapper signature be identical to the C function signature? The answer to "clearer" is not necessarily the same as the answer to "better". For this class I'm not sure how much time I can spend on Python's ctypes. If I shove it under the rug then the answer might change.
Anyway, a penny for your thoughts. I think I'm in favor of the former technique as opposed to the verbose latter technique even if it does hide the C-side.