Re: recursive decorator

2009-09-08 Thread Ethan Furman
Michele Simionato wrote: [snip] Yes, it is portable. BTW, here is what you want to do (requires decorator-3.1.2): from decorator import FunctionMaker def bindfunc(f): name = f.__name__ signature = ', '.join(FunctionMaker(f).args[1:]) # skip first arg return FunctionMaker.create(

Re: recursive decorator

2009-09-05 Thread Michele Simionato
> def enable_recur(f): >     print f.func_code.co_names >     if 'recur' not in f.func_code.co_names: >         return f # do nothing on non-recursive functions >     c = Code.from_code(f.func_code) >     c.code[1:1] = [(LOAD_GLOBAL, f.__name__), (STORE_FAST, 'recur')] >     for i, (opcode, value)

Re: recursive decorator

2009-09-04 Thread sturlamolden
On 4 Sep, 14:50, Michele Simionato wrote: > # requires byteplay by Noam Raphael > # seehttp://byteplay.googlecode.com/svn/trunk/byteplay.py > from byteplay import Code, LOAD_GLOBAL, STORE_FAST, LOAD_FAST Incrediby cool :-) -- http://mail.python.org/mailman/listinfo/python-list

Re: recursive decorator

2009-09-04 Thread Michele Simionato
On Sep 4, 7:03 pm, Ethan Furman wrote: > Just to verify, using the decorator module is portable, yes? Yes, it is portable. BTW, here is what you want to do (requires decorator-3.1.2): from decorator import FunctionMaker def bindfunc(f): name = f.__name__ signature = ', '.join(FunctionM

Re: recursive decorator

2009-09-04 Thread Ethan Furman
Michele Simionato wrote: On Sep 3, 6:41 pm, Ethan Furman wrote: The original thread by Bearophile: http://mail.python.org/pipermail/python-list/2009-May/711848.html I have read the thread. What Bearophile wants can be implemented with a bytecode hack, no need for the decorator module. Let

Re: recursive decorator

2009-09-04 Thread Michele Simionato
On Sep 3, 6:41 pm, Ethan Furman wrote: > > The original thread by Bearophile: >    http://mail.python.org/pipermail/python-list/2009-May/711848.html I have read the thread. What Bearophile wants can be implemented with a bytecode hack, no need for the decorator module. Let me call 'recur' the sel

Re: recursive decorator

2009-09-03 Thread Ethan Furman
Michele Simionato wrote: On Sep 3, 12:19 am, Ethan Furman wrote: Greetings, List! The recent thread about a recursive function in a class definition led me back to a post about bindfunc from Arnaud, and from there I found Michele Simionato's decorator module (many thanks! :-), and from there

Re: recursive decorator

2009-09-03 Thread Michele Simionato
On Sep 3, 12:19 am, Ethan Furman wrote: > Greetings, List! > > The recent thread about a recursive function in a class definition led > me back to a post about bindfunc from Arnaud, and from there I found > Michele Simionato's decorator module (many thanks! :-), and from there I > began to wonder.