-
Notifications
You must be signed in to change notification settings - Fork 162
Move callback wrappers to Python layer #544
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
Conversation
/ok to test |
This comment has been minimized.
This comment has been minimized.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I have reviewed 3 out of 4 files (haven't had time to cover runtime.pyx.in
yet).
Q: I assume so far we have not supported passing a pure Python function as callback to any of the bindings directly, without using ctypes or other means as a trampoline?
cdef cuAsyncCallbackData *cbData = NULL | ||
cbData = <cuAsyncCallbackData *>malloc(sizeof(cbData[0])) | ||
if cbData == NULL: | ||
return CUresult.CUDA_ERROR_OUT_OF_MEMORY |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Q: Should this be a 1-tuple?
return CUresult.CUDA_ERROR_OUT_OF_MEMORY | |
return (CUresult.CUDA_ERROR_OUT_OF_MEMORY,) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Good catch. Fixed.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It would be good to have type annotations or something else as a way to prevent issues like this from sneaking in.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It seems currently Cython cannot raise a compile-time error for either case, only a run-time error (which is not desired I think).
cpdef tuple f():
return 42
def g() -> tuple:
return 42
Output:
>>> import test_tuple
>>> test_tuple.f()
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
File "test_tuple.pyx", line 1, in test_tuple.f
cpdef tuple f():
File "test_tuple.pyx", line 3, in test_tuple.f
return 42
TypeError: Expected tuple, got int
>>> test_tuple.g()
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
File "test_tuple.pyx", line 7, in test_tuple.g
return 42
TypeError: Expected tuple, got int
Correct. |
/ok to test |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM!
|
close #531