On Fri, Apr 27, 2012 at 7:39 AM, Ian Kelly <ian.g.ke...@gmail.com> wrote: > I'm not sure precisely what you mean by "temporary object", so I am > taking it to mean an object that is referenced only by the VM stack > (or something equivalent for other implementations). > > In that case: no, you can't. Take "f() is g()", where the code > objects of f and g are supplied at runtime. Are the objects returned > by either of those expressions "temporary"? Without being able to do > static analysis of the code of f and g, there is no way to know.
The expression itself will have references to all its operands (at least conceptually). If their refcounts are precisely 1, then the objects are temporaries and will be disposable as soon as the expression's fully evaluated. ChrisA -- http://mail.python.org/mailman/listinfo/python-list