Re:Goto decorator for python
by baq on Sunday March 11, 2012 @07:27PM
(#3691617)
your example breaks down when objects overriding __mul__ and __add__ are passed as a. that's the most important reason python doesn't do anything with code like this. you want a jit doing specialization and inlining for you (see tracing jit in pypy or, to a lesser extent, psyco.)
[ Parent
| on HN ]
Re:Goto decorator for python
by anonymoushn on Sunday March 11, 2012 @07:55PM
(#3691700)
For what value of __mull__ and __add__ does f(g(x)) produce a different result than h(x)? You could do this by making __mul__ or __add__ change behavior based on stack inspection, but I am having trouble thinking of another way.
Re:Goto decorator for python
by alextgordon on Sunday March 11, 2012 @09:07PM
(#3691898)
A backtrace would be different, for a start. If __mul__ raises an exception, it would not show as coming from g(). Makes debugging a little bit harder.