[Python-Dev] Re: instances as buffers

David Ascher da@ski.org
Sun, 15 Aug 1999 14:07:35 -0700 (Pacific Daylight Time)


On Sun, 15 Aug 1999, Greg Stein wrote:

> How do you manage the lifetimes of the memory and objects?
> PyBuffer_FromReadWriteMemory() creates a buffer object that points to
> memory. You need to ensure that the memory exists as long as the buffer
> does.

For those cases where I use PyBuffer_FromReadWriteMemory, I have no
control over the memory involved.  Windows allocates the memory, lets me
use it for a litle while, and it cleans it up whenever it feels like it.
It hasn't been a problem yet, but I agree that it's possibly a problem.
I'd call it a problem w/ the win32 API, though.

> Would it make more sense to use PyBuffer_New(size)?

Again, I can't because I am given a pointer and am expected to modify e.g.
bytes 10-12 starting from that memory location.

> This is a very cool class. Mark and I had discussed doing something just
> like this (a while back) for some of the COM stuff. Basically, we'd want
> to generate these structures from type libraries.

I know zilch about type libraries.  This is for CE work, although none
about this class is CE-specific.  Do type libraries give the same kind of
info?

> You can do #3 today since there is a buffer typecode present ("w" or
> "w#"). It will complicate Python code a bit since you need to pass the
> buffer, but it is the simplest of the three options.

Ok.  Time to patch SWIG again!

--david