Skip to content

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.

@fschrempf
Copy link
Collaborator

Superseded by #83

@fschrempf fschrempf closed this Sep 25, 2025
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.

3 participants