INCREF DECREF manually

2010-05-10 Thread moerchendiser2k3
Hi,

just a small question. Is it possible to change the refcount of a
reference manually? For debugging / ...

Thanks!

moerchendiser2k3
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: INCREF DECREF manually

2010-05-10 Thread Jean-Michel Pichavant

moerchendiser2k3 wrote:

Hi,

just a small question. Is it possible to change the refcount of a
reference manually? For debugging / ...

Thanks!

moerchendiser2k3
  
Why don't you just create a global reference to the object ? Unless this 
one is removed, the object will be kept in memory.


JM
--
http://mail.python.org/mailman/listinfo/python-list


Re: INCREF DECREF manually

2010-05-10 Thread moerchendiser2k3

Do to some debugging if a version contains a bug and needs to be fixed
there manually.
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: INCREF DECREF manually

2010-05-10 Thread Antoine Pitrou
On Mon, 10 May 2010 07:26:42 -0700 (PDT)
moerchendiser2k3 googler.1.webmas...@spamgourmet.com wrote:
 
 Do to some debugging if a version contains a bug and needs to be fixed
 there manually.

This is certainly the wrong approach.
To know if your Python code is leaking references, use either
sys.getrefcount(), or (better) a weakref -- and don't forget to
call gc.collect().
To know if some C extension is buggy, use your C debugger (or your
favourite alternative debugging method, such as printf()).

Changing reference counts from Python will lead to two possible
consequences:
- if you increment a reference count, you will have a permanent memory
  leak
- if you decrement a reference count, you will eventually crash the
  interpreter


-- 
http://mail.python.org/mailman/listinfo/python-list