61 ms·
Less restricted anonymous functions would allow stuff like this: fib=memoize(function...) So the @ shortcut for: def fib(): ... fib=memoi
by maxerickson 15y ago
Less restricted anonymous functions would allow stuff like this:
fib=memoize(function...)
So the @ shortcut for:
def fib():
...
fib=memoize(fib)
wouldn't be necessary to 'clean up' the decoration of the function.
- irahul 15y agoEven if it were possible, I would stick with @memoize def fib: pass fib = memoize(function ...) has unnecessary nesting, and @memoize is cleaner IMO. I am curious - do you find @memoize confusing? Personally for me and anyone I have talked to, @memoize is vanilla - the confusing part is the decorator itself, especially one that takes arguments; that coupled with the fact that classes(which override __call__) and functions are both used as decorators.
- maxerickson 15y agoNo, I don't find it confusing. But I read craigyk as mostly talking about the special decorator syntax, not function decoration in general.