-
Notifications
You must be signed in to change notification settings - Fork 205
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
Readbytesb -- return bytes object for efficiency #80
base: master
Are you sure you want to change the base?
Conversation
spidev_module.c
Outdated
Py_buffer pybuff; | ||
uint8_t* rxbuf = stackbuf; | ||
|
||
if (resultType == 2) { //existing bytearray |
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.
Please remove magic numbers (Add #define for resultType
)
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.
Thanks for the PR! I will merge this if you replace the 0, 1, 2 resultType
values with #define
's.
Good call on the magic numbers. I think perhaps my refactoring is a bit heavy handed anyway, and I've changed it a bit. |
wow ... my first ever pull request! Also my first ever python C-api foray.
So apologies if I've done anything stupid...
added readbytesb which returns a bytes object rather than a list. This can, for example be fed directly into numpy.frombuffer giving more efficient transfer as no list needs to be built.