This issue tracker has been migrated to GitHub, and is currently read-only.
For more information, see the GitHub FAQs in the Python's Developer Guide.

Author eric.snow
Recipients eric.snow
Date 2011-08-30.05:54:24
SpamBayes Score 3.8073924e-08
Marked as misclassified No
Message-id <1314683667.85.0.876885324202.issue12857@psf.upfronthosting.co.za>
In-reply-to
Content
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
History
Date User Action Args
2011-08-30 05:54:28eric.snowsetrecipients: + eric.snow
2011-08-30 05:54:27eric.snowsetmessageid: <1314683667.85.0.876885324202.issue12857@psf.upfronthosting.co.za>
2011-08-30 05:54:27eric.snowlinkissue12857 messages
2011-08-30 05:54:26eric.snowcreate