[Python-ideas] Access to function objects
tjreedy at udel.edu
Sun Aug 7 08:17:22 CEST 2011
On 8/7/2011 12:32 AM, Eric Snow wrote:
> On Sat, Aug 6, 2011 at 2:28 PM, Terry Reedy<tjreedy at udel.edu> wrote:
>> This proposal/desire comes up constantly on python-list, generally with
>> support. I believe it was part of two recent threads. I would like to know
>> if the rejection of the idea so far is a rejection in principle (and if so,
>> why) or a rejection of specifics.
> Of the three code blocks, functions are the only ones for whom the
> resulting object and the execution of the code block are separate. So
> a code object could be executing for the original function or a
> different one that is sharing the code object.
Now I remember that the separation between code object and function
object and the possibility of reusing code objects has been given as a
reason to reject the idea. On the other hand, reusing code objects is so
rare that I question the need to cater to it much.
> Why not bind the called function-object to the frame locals, rather
> than the one for which the code object was created, perhaps as
I do not understand this.
> To finish things off, bind to every new code object
> the function for which it was created, perhaps as "co_func". That way
> you will always know what function object was called and which one the
> code object came from originally.
I don't see that solving the problem of how the function code accesses
the object. Adding something to the default arg tuple might make more
Terry Jan Reedy
More information about the Python-ideas