On Tue, 02 Nov 2010 13:19:06 +0100, Giovanni Bajo <ra...@develer.com> wrote: > On mar, 2010-11-02 at 13:57 +0200, Hans-Peter Jansen wrote: >> On Tuesday 02 November 2010, 11:26:46 Giovanni Bajo wrote: >> > On mar, 2010-11-02 at 10:16 +0000, Phil Thompson wrote: >> > > On Tue, 2 Nov 2010 00:00:06 +0200, "Hans-Peter Jansen" >> > > <h...@urpla.net> >> > > >> > > wrote: >> > > > Hi Phil, >> > > > >> > > > end of July last year, Alexandre Raczynski asked about accessing >> > > > QSharedMemory, and you replied, that: >> > > > >> > > > mutable_data = buffer(sharedMemory.data()) >> > > > >> > > > ...should give _write_ access to the memory. >> > > >> > > ...bad advice. I didn't realise that you can't create mutable >> > > buffers from Python. (Although there is no reason why you shouldn't >> > > be able to.) >> > >> > Actually, Python 2.7 has memoryview(); if >> > memoryview(sharedMemory.data()) worked, it would be possible to use >> > memoryview's method to mutate the buffer, without having to come up >> > with a different API for sip.voidptr. >> >> Giovanni, isn't memoryview just a different _interface_ to the buffer >> protocol? > > To the best of my understanding, it is a more complete interface that > also allows writable buffers. I think it is the best match to allow > access to the "contents" of a sip.voidptr and its const version.
Agreed - it's implemented in the hg repo. >> Anyway, being able to use QSharedMemory with 2.7 and higher >> only looks like an arbitrary restriction to me. At least many of my >> production systems would be locked out, then. For proper support, Phil >> might have to do both variants of the buffer protocol anyway.. > > I understand your concerns. Support for memoryview (as a silent > conversion to/from void* at SIP level) would still be required for > interoperability with libraries which don't know sip.voidptr but can > use/produce a memoryview. > > I was just wondering if there was a better solution than coming up with > a custom API for sip.voidptr for pre-2.7, but I can't see it. It's not really a custom API - just standard slice and index assignment. Phil _______________________________________________ PyQt mailing list PyQt@riverbankcomputing.com http://www.riverbankcomputing.com/mailman/listinfo/pyqt