Skip to content

Conversation

jmuchemb
Copy link

@jmuchemb jmuchemb commented Dec 6, 2023

First commit is important for performance because it avoids useless data copies when the caller provides a mutable buffer. Locally, I have an incomplete micropython-compat layer that I'd like to write as follows:

    def readfrom_into(self, addr, buf, stop=True):
        self.transfer(addr, [self.Message(buf, read=True)])

But without this PR, I'd have to do:

    def readfrom_into(self, addr, buf, stop=True):
        msg = self.Message(buf, read=True)
        self.transfer(addr, [msg])
        buf[:] = msg.data

(off-topic: I don't know yet what to with the stop=True parameter)

The next 2 commits are less important. They only relax some typing constraints, for free. I haven't checked my changes to i2c.pyi.

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.

1 participant