4 ms·
I’ve never used buffers, but my understanding is that you can modify the contents directly from python without even needing a C extension. Surely I could trigge
by NotYourLawyer 4y ago
I’ve never used buffers, but my understanding is that you can modify the contents directly from python without even needing a C extension. Surely I could trigger UB by just scribbling into the data structure for one of python’s native types and then accessing it normally.
- quietbritishjim 4y agoI don't think that's true - you can use the buffer protcol to give one object a view into another but those objects' classes need to be written in C in order to allow that exchange to happen. But if even if you were able to modify a buffer-protocol buffer directly using native Python, that would keep the GIL locked, which would prevent simultaneous access from multiple threads.