[Python-Dev] Please reconsider PEP 479.

Guido van Rossum guido at python.org
Thu Nov 27 01:33:54 CET 2014


The design just copies the code object with one flag set differently. Code
objects are immutable but they can be copied (though the interface to do
that is kind of hidden).

On Wed, Nov 26, 2014 at 4:03 PM, Chris Angelico <rosuav at gmail.com> wrote:

> On Thu, Nov 27, 2014 at 9:53 AM, Nick Coghlan <ncoghlan at gmail.com> wrote:
> > The implicit stop decorator would then check the flags on the code object
> > attached to the passed in function. If GENERATOR wasn't set, that would
> be
> > an immediate ValueError, while if EXPLICIT_STOP wasn't set, the generator
> > function would be passed through unmodified. However, if EXPLICIT_STOP
> *was*
> > set, the generator function would be replaced by a *new* generator
> function
> > with a *new* code object, where the only change was to clear the
> > EXPLICIT_STOP flag.
>
> Is it possible to replace the code object without replacing the
> function? Imagine if you have multiple decorators, one of which
> retains a reference to the function and then this one which replaces
> it - the order of decoration would be critical. OTOH, I don't know
> that anyone would retain references to __code__.
>
> ChrisA
> _______________________________________________
> Python-Dev mailing list
> Python-Dev at python.org
> https://mail.python.org/mailman/listinfo/python-dev
> Unsubscribe:
> https://mail.python.org/mailman/options/python-dev/guido%40python.org
>



-- 
--Guido van Rossum (python.org/~guido)
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.python.org/pipermail/python-dev/attachments/20141126/9ce9938d/attachment.html>


More information about the Python-Dev mailing list