Hi,
the Python/C-API says that we allways have to return owned references.
Example:

// C-Code
static
PyObject * f (PyObject *self, PyObject *args) {
   PyObject * rtn = NULL;
   PyArg_ParseTuple(args, "s", &rtn);

   Py_INCREF(rtn);
   return rtn;
}
#Python-Code

a=myType()
b=a.f("hello world")

a.f("hello world")

I understand the first call. Python builts a tuple and puts in the string. After f() is done the Interpreter del's the tuple and so the string would be lost if I don't incref it before.
But what does the Interpreter do in case of a.f("hello world")? Does the interpreter checks if an assignment was done and if not does it decrements the refcount of the returned object immediately? I guess it has to but I'm not sure. May anybody help me with that? Thanks a lot.

Jonny

Hi,

anybody has an idea??

Jonny