FAQFAQ   SearchSearch   MemberlistMemberlist   UsergroupsUsergroups   RegisterRegister 
 ProfileProfile   Log in to check your private messagesLog in to check your private messages   Log inLog in 

How to create a reference from an object created in python

 
Post new topic   Reply to topic     Forum Index -> PyD
View previous topic :: View next topic  
Author Message
simhau



Joined: 06 Feb 2007
Posts: 55

PostPosted: Tue May 15, 2007 8:14 am    Post subject: How to create a reference from an object created in python Reply with quote

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
View user's profile Send private message
KirkMcDonald



Joined: 22 Jun 2006
Posts: 23

PostPosted: Wed May 23, 2007 10:32 am    Post subject: Reply with quote

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
View user's profile Send private message
Display posts from previous:   
Post new topic   Reply to topic     Forum Index -> PyD All times are GMT - 6 Hours
Page 1 of 1

 
Jump to:  
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum


Powered by phpBB © 2001, 2005 phpBB Group