doceme / py-spidev

MIT License
461 stars 203 forks source link

Readbytesb -- return bytes object for efficiency #80

Open aardvarkkrill opened 5 years ago

aardvarkkrill commented 5 years ago

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 commented 5 years ago

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.