Skip to content
Discussion options

You must be logged in to vote
* what is the difference between them?

As Andrew said, the _raise version will raise an exception for you if the buffer doesn't support the requested read/write mode.

* who controls the buffer returned? Is it just a pointer to the micropython buffer, or a copy?

It's owned by the object that gave you the buffer.

In general it's not safe to hold onto this if you're going to let other code run (i.e. return to Python).

If you're sure that the object won't change its buffer, then you can hold onto the pointer as long as you also ensure that the object won't be garbage collected.

If the object can change its buffer then you shouldn't keep the pointer, instead keep the mp_obj_t and use mp_…

Replies: 3 comments 4 replies

Comment options

andrewleech
Sep 15, 2023
Collaborator Sponsor

You must be logged in to vote
0 replies
Comment options

You must be logged in to vote
4 replies
@jimmo
Comment options

@jimmo
Comment options

@glenn20
Comment options

@jimmo
Comment options

Answer selected by brianwyld
Comment options

You must be logged in to vote
0 replies
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
ESP32
Labels
None yet
4 participants