[capi-sig] Does Py_False or Py_True need de-referencing if used in a PyObject_Compare?
python_capi at behnel.de
Sat Dec 15 15:33:27 CET 2012
Robert Steckroth, 13.12.2012 17:57:
> Well, from what I have gathered, the reference count does not need to be
> maintain as far as PyBool objects go.
They are like any other object, i.e. they need reference counting.
> It seem to be fine even if the object is set from a argument. Hmmm...
That's a different case. As long as you are sure that someone (better you)
owns a reference to the object that you pass as argument, you don't need to
increase its refcount just for the call. That's easy to get wrong, though.
>> Does the below statement have a memory leak?
>> if ( PyObject_Compare(update_var, Py_False)
Why should it?
>> Do I need to assign the Py_False first and DECREF it, or is the above
>> snippet ok alone.
I keep being surprised by what some people take their fun in programming
from. Good to see that you're getting actual functionality done regardless.
More information about the capi-sig