Re: [Pyobjc-dev] PyBuffer* vs. array.array()
Brought to you by:
ronaldoussoren
From: Ronald O. <ous...@ci...> - 2003-01-05 16:07:38
|
On Sunday, Jan 5, 2003, at 05:56 Europe/Amsterdam, Bill Bumgarner wrote: > > The real problem is that something created via array.array() comes > back as an object that behaves differently. Clearly, a bug in my > bridge code, yes, but raises a question: > > What should I be using? > > From the python side, it appears to only be possible to create buffer > style objects-- big byte bags-- via the array module [yes a <str> will > work, but a byte-array seems so much more correct]. On the C side, it > seems that the only way to create a byte buffer like object is to use > the PyBuffer* API. You could use the array module on the C side. That is more work than just using the PyBuffer API but would solve your problem. <advocate style=devil> However, what if I raw strings into the API. If I get array objects back from the API there still is an inconsistency. </advocate> I agree that array objects are more suitable for 'bags of bytes' than the (builtin) alternatives. Note that some people seem to use Numeric python for image processing (http://www.pfdubois.com/numpy/). Adding support for using numeric arrays instead of array.array might be a usefull extension, but probably more as an item on the TODO list than something to implement right now. All things considered I'd go for using array.array from C, with a fallback to the PyBuffer API when you cannot import the array module. Ronald |