Decrementing of reference count of new objects?

Discussion in 'Python' started by Mitko Haralanov, Apr 1, 2008.

  1. For the most part, I understand the theory behind reference counting in
    Python C code. But there is one thing that I am confused about and I
    have not been able to clear it up.

    Let say that you have the following function (over-simplified):

    PyObject *do_work (PyObject *self, PyObject *args) {
    PyObject *new_obj;
    new_obj = PyDict_New ();
    return new_obj;
    }

    What I don't get is whether I have to decrement the reference to
    new_obj before I return it. I know that function that return object are
    giving away the reference but I am still confused.

    Thanks for all your help!
    --
    Mitko Haralanov
    Senior Software Engineer 650.934.8064
    HSG InfiniBand Engineering http://www.qlogic.com

    ==========================================
    11. Any more trouble from you and your account gets moved to the 750

    --Top 100 things you don't want the sysadmin to say
    Mitko Haralanov, Apr 1, 2008
    #1
    1. Advertising

Want to reply to this thread or ask your own question?

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. J. Campbell
    Replies:
    6
    Views:
    468
    Peter van Merkerk
    Aug 19, 2003
  2. srikanth
    Replies:
    5
    Views:
    304
    CBFalconer
    Mar 9, 2006
  3. pozz
    Replies:
    10
    Views:
    504
  4. Bill Cunningham

    decrementing arrays

    Bill Cunningham, Jun 20, 2008, in forum: C Programming
    Replies:
    77
    Views:
    1,422
  5. Une bévue

    for loop decrementing ?

    Une bévue, Jul 8, 2006, in forum: Ruby
    Replies:
    2
    Views:
    94
    Une bévue
    Jul 8, 2006
Loading...

Share This Page