[Python-Dev] PEP: Adding data-type objects to Python (original) (raw)
Bill Baxter wbaxter at gmail.com
Wed Nov 1 02:58:41 CET 2006
- Previous message: [Python-Dev] PEP: Extending the buffer protocol to share array information.
- Next message: [Python-Dev] PEP: Adding data-type objects to Python
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]
One thing I'm curious about in the ctypes vs this PEP debate is the following. How do the approaches differ in practice if I'm developing a library that wants to accept various image formats that all describe the same thing: rgb data. Let's say for now all I want to support is two different image formats whose pixels are described in C structs by:
struct rbg565 { unsigned short r:5; unsigned short g:6; unsigned short b:5; };
struct rgb101210 { unsigned int r:10; unsigned int g:12; unsigned int b:10; };
Basically in my code I want to be able to take the binary data descriptor and say "give me the 'r' field of this pixel as an integer".
Is either one (the PEP or c-types) clearly easier to use in this case? What would the code look like for handling both formats generically?
--bb
- Previous message: [Python-Dev] PEP: Extending the buffer protocol to share array information.
- Next message: [Python-Dev] PEP: Adding data-type objects to Python
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]