Int tuple element scope

Discussion in 'Python' started by Ron Griswold, May 11, 2004.

  1. Ron Griswold

    Ron Griswold Guest

    Can anyone tell me why the following will cause the returned tuple elements to remain un collected when the tuple goes out of scope:

    PyObject * iobj = PyObject_New( PyIntObject, &PyInt_Type );
    iobj->ob_ival = val;
    PyTuple_SetItem( tuple, index, iobj );
    return tuple;

    while the following will collect the elements:

    PyTuple_SetItem( tuple, index PyInt_FromLong( val ) );
    return tuple;

    both PyObject_New and PyInt_FromLong return new references and I have verified that in all cases the refcount upon return is 1 for all objects involved. So I'm just wondering if I'm missing something fundamental.

    Thanks in advance!

    Ron
    Ron Griswold, May 11, 2004
    #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. Schnoffos
    Replies:
    2
    Views:
    1,188
    Martien Verbruggen
    Jun 27, 2003
  2. Hal Styli
    Replies:
    14
    Views:
    1,604
    Old Wolf
    Jan 20, 2004
  3. Michal Mikolajczyk
    Replies:
    1
    Views:
    786
    Larry Bates
    Apr 20, 2004
  4. Jeff Epler
    Replies:
    0
    Views:
    915
    Jeff Epler
    Apr 20, 2004
  5. Bill Scherer
    Replies:
    0
    Views:
    599
    Bill Scherer
    Apr 20, 2004
Loading...

Share This Page