[Python-ideas] make __closure__ writable

Tim Delaney timothy.c.delaney at gmail.com
Thu Mar 29 10:27:54 CEST 2012

On 29 March 2012 19:05, Mark Shannon <mark at hotpy.org> wrote:

> Tim Delaney wrote:
>> There are many things you can do with bytecode manipulation (whether you
>> should is another question). Among other things, I've used it for
>> optimisation (e.g. my optimised self.super recipe that probably isn't
>> actually available online anymore). Instrumentation of code is another
>> thing, although these days you're probably better off using a decorator.
>> There aren't a lot of real use cases, but if nothing else it can be a lot
>> of fun :)
> You can do all of those things without changing the __code__ attribute.
> Just create a new function instead.

Not if you want anything that holds an existing reference to the function
to get the new behaviour. Sometimes you need to change things in-place.

Tim Delaney
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.python.org/pipermail/python-ideas/attachments/20120329/d810cd87/attachment.html>

More information about the Python-ideas mailing list