[C++-sig] (How) can I "attach" code/objects to a standard Python object?

Hans Meine hans_meine at gmx.net
Fri Aug 17 22:50:16 CEST 2007


Hi!

Ultimately, I want to be able to create numpy arrays wrapping existing (2D 
imagaee) data.  I succeeded so far by exposing a function using 
PyBuffer_FromReadWriteMemory with BPL and then use numpy.frombuffer from 
Python.

The problem I have is that PyBuffer_FromReadWriteMemory returns a PyBuffer 
object which points to my data, and I have to make sure that my own object 
(which internally holds a boost::shared_ptr to a Memory object) does not free 
the memory.  (How) can I tie the lifetime of my Image object (or the 
internal, already shared_ptr'ed Memory object) to the PyBuffer?  Is there 
another, better way to proceed?

Thanks in advance,
   Hans
-------------- next part --------------
A non-text attachment was scrubbed...
Name: not available
Type: application/pgp-signature
Size: 189 bytes
Desc: This is a digitally signed message part.
URL: <http://mail.python.org/pipermail/cplusplus-sig/attachments/20070817/f2b0344a/attachment.pgp>


More information about the Cplusplus-sig mailing list