Message143201
This patch adds f_func to PyFrameObject and sets it for functions that get called (in PyFrame_New). For classes and modules it is set to None. The difference in performance was not noticable, as far as I could tell. However, I am willing to do more than just time 'make test' a few times if there is any concern.
A couple weeks ago a thread on python-ideas centered on the subject matter of PEP 3130[1]. The discussion started with, and mainly involved, the idea of adding __function__ to the frame locals during execution of the function. __function__ would point to the function that was called, which had resulted in the frame.
I spent quite a bit of time getting this to work using a closure, but the result was overkill. It also made it too easy to use __function__ for recursion, which Guido did not like (and I agree).
At this point it dawned on me that it would be much simpler to just add the called function to the frame object. This patch is the result. In the end it is much more efficient than the locals approach I had been taking.
[1] http://mail.python.org/pipermail/python-ideas/2011-August/011062.html |
|
Date |
User |
Action |
Args |
2011-08-30 05:54:28 | eric.snow | set | recipients:
+ eric.snow |
2011-08-30 05:54:27 | eric.snow | set | messageid: <1314683667.85.0.876885324202.issue12857@psf.upfronthosting.co.za> |
2011-08-30 05:54:27 | eric.snow | link | issue12857 messages |
2011-08-30 05:54:26 | eric.snow | create | |
|