Skip to content

Wrapper Interface Design #1

Description

@cswiercz

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 signature

void vec_add(double* out, double* x, double* y, int N);

whereas I've written the Python wrapper homework2.vec_add to have the signature

def vec_add(x, y):
    # return the sum of x and y by calling the C vec_add function via ctypes

The 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.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions