Newsgroups: comp.lang.python
From: Miguel Perez <Wiseman1...@gmail.com>
Date: Wed, 26 Sep 2007 13:40:44 -0000
Local: Wed, Sep 26 2007 9:40 am
Subject: My tail call optimizing decorator
Please critique this tail call optimizing decorator I've written. I've
tried to fix the pitfalls of other proposed decorators, and the result is this one that supports mutual recursion, does not use exceptions, stack inspection or any implementation-dependent hack, and is pretty short and fast - the fastest out of the ones I could find and try. In fact, in tail-recursive environments I tested the impact of using the decorator is difficult to even measure, as the extra time the decorator takes to run is probably saved by the better use of cache memory. The only caveat is that if used in a function that's not called in a tail-recursive fashion, bad things will happen. def tailcall(f): Supports cooperative tail call - even when only one of the functions The only caveat is that if you attempt to decorate a function that You must Sign in before you can post messages.
To post a message you must first join this group.
Please update your nickname on the subscription settings page before posting.
You do not have the permission required to post.
| ||||||||||||||