View previous topic :: View next topic |
Author |
Message |
simhau
Joined: 06 Feb 2007 Posts: 55
|
Posted: Tue May 15, 2007 8:14 am Post subject: How to create a reference from an object created in python |
|
|
If I create an Object in python and passes it to my D class (that stores it in an array). When the object goes out of scope it is destroyed, so the interpreter crashes when I'm trying to access the element.
How can I be sure that a reference is created so the garbage collector doesn't destroy it? |
|
Back to top |
|
|
KirkMcDonald
Joined: 22 Jun 2006 Posts: 23
|
Posted: Wed May 23, 2007 10:32 am Post subject: |
|
|
What is the D class storing, exactly? A D Object or a PyObject*? If it is storing PyObject*s, you will have to deal with reference counts like any code using the Python/C API. (That is, you'll have to use Py_INCREF and Py_DECREF.) |
|
Back to top |
|
|
|