[C++-sig] Instantiate a wrapped class in C++ and get the PyObject pointer

David Sveningsson ext at sidvind.com
Mon Apr 23 22:42:42 CEST 2007

> object a_instance = A(...); // Create an A instance and wrap it in a
> python object
> PyObject *ptr = a_instance.ptr(); // access a C API pointer from the
> instance

But if I return a_instance.ptr() the object will be corrupt right? But if
I allocate on the heap it will leak memory?

More information about the Cplusplus-sig mailing list