[Python-Dev] cpython: Add Py_RETURN_NOTIMPLEMENTED macro. Fixes #12724.

Antoine Pitrou solipsis at pitrou.net
Mon Aug 15 14:17:23 CEST 2011


Le lundi 15 août 2011 à 13:16 +1000, Nick Coghlan a écrit :
> On Mon, Aug 15, 2011 at 12:34 PM, Brett Cannon <brett at python.org> wrote:
> > On Thu, Aug 11, 2011 at 00:02, Antoine Pitrou <solipsis at pitrou.net> wrote:
> >> It would sound more useful to have a generic Py_RETURN() macro rather than
> >> some specific forms for each and every common object.
> >
> > Since the macro is rather generic, sure, but the name should probably be
> > better since it doesn't necessarily convene the fact that a INCREF has
> > occurred. So maybe Py_INCREF_RETURN()?
> 
> Aside from None and NotImplemented, do we really do the straight
> incref-and-return all that often?

AFAICT, often with True and False:

    x = (some condition) ? Py_True : Py_False;
    Py_INCREF(x);
    return x;

Regards

Antoine.




More information about the Python-Dev mailing list