[Python-ideas] make __closure__ writable
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.
-------------- next part --------------
An HTML attachment was scrubbed...
More information about the Python-ideas