Skip to content
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

Open
wants to merge 9 commits into
base: master
Choose a base branch
from

Conversation

aardvarkkrill
Copy link

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.

@aardvarkkrill aardvarkkrill changed the title Readbytesb Readbytesb -- return bytes object for efficiency Feb 21, 2019
spidev_module.c Outdated
Py_buffer pybuff;
uint8_t* rxbuf = stackbuf;

if (resultType == 2) { //existing bytearray
Copy link
Owner

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)

Copy link
Owner

@doceme doceme left a 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.

@aardvarkkrill
Copy link
Author

Good call on the magic numbers. I think perhaps my refactoring is a bit heavy handed anyway, and I've changed it a bit.
I added another function (which is probably the one I should have written first) and I'll make a separate pull request for that... again I'm new here, sorry if this is wrong.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants