[Python-Dev] Extended Buffer Protocol - simple use examples (original) (raw)
Travis Oliphant oliphant.travis at ieee.org
Mon Apr 9 22:26:16 CEST 2007
- Previous message: [Python-Dev] Extended Buffer Protocol - simple use examples
- Next message: [Python-Dev] Extended Buffer Protocol - simple use examples
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]
Paul Moore wrote:
Hi, I'll admit right off that I haven't followed all of the extended buffer protocol discussions - I have no real need for anything much beyond the existing "here's a blob of memory" level of functionality.
I have skimmed (briefly, I'll admit!) the pre-PEP, but I've found it extremely difficult to find a simple example of the basic (in my view) use case of an undifferentiated block of bytes.
This is a great suggestion and it was on my to-do list. I've included some examples of this use-case in the new PEP.
1. (Producer) I have a block of memory in my C extension and I want to expose it as a simple contiguous block of bytes to Python.
This is now Ex. 2 in the PEP.
2. (Consumer) I want to get at a block of memory exposed as a buffer. I am only interested in, and only support, viewing a buffer as a block of contiguous bytes. I expect most if not all extensions to be able to provide such a view.
This is now Ex. 3
Thanks for the suggestions.
-Travis
- Previous message: [Python-Dev] Extended Buffer Protocol - simple use examples
- Next message: [Python-Dev] Extended Buffer Protocol - simple use examples
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]