On Tue, Aug 5, 2008 at 4:30 PM, Paul Pogonyshev <[EMAIL PROTECTED]> wrote:

> > Generally, I end up storing all the objects to be Py_DECREF'd in
> temporary
> > variables and doing the Py_DECREF's just before returning.  That way,
> "self"
> > is never in an inconsistent state.
>
> Right.  But wouldn't it be easier if there was a standard Python macro
> for this, sort of like proposed Py_ASSIGN?
>

If you're modifying exactly one property in the C function, yes.

In my C code, when I modifying an object I usually need to modifying many of
the properties which means that I need to delay all of the Py_DECREF's until
just before returning.  The Py_ASSIGN macro that you propose would not
achieve this.  If I used Py_ASSIGN, all the pointers would point to valid
objects, true, but the object might not be in a consistent state.

If in your code you frequently need to modifying just one property, you are
certainly free to create your own macro. :-)

--
Daniel Stutzbach, Ph.D.
President, Stutzbach Enterprises, LLC <http://stutzbachenterprises.com>
_______________________________________________
Python-Dev mailing list
[email protected]
http://mail.python.org/mailman/listinfo/python-dev
Unsubscribe: 
http://mail.python.org/mailman/options/python-dev/archive%40mail-archive.com

Reply via email to