[Python-Dev] Accessing globals without dict lookup
Tim Peters
tim.one@comcast.net
Sun, 10 Feb 2002 16:51:59 -0500
Sun, 10 Feb 2002 16:51:59 -0500
- Previous message: [Python-Dev] Accessing globals without dict lookup
- Next message: [Python-Dev] Accessing globals without dict lookup
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]
[Skip Montanaro] > I'm still working my way through this thread, so forgive me if > this has been hashed out already. It seems to me that the correct > thing to do is to convert plain dicts to celldicts when creating > functions. There's the problem of object identity: it's possible for exec'ed code to mutate the original dict while the exec'ed code is running, and Guido gave an example where that can matter. I had originally suggested building a celldict that *contained* the original dict, reflecting mutations from the former to the latter as they happened. Mutations in the other direction go unnoticed, though. If the binary layouts are compatible enough, it may suffice to replace the dict's type pointer for the duration. Even then, the exec'ed code may get tripped up via testing (directly or indirectly) the type of the original dict (I suppose it could lie about its type ...). > Besides, where are functions going to get created that are outside > of your (PyhonLabs) control? They aren't, but eval and exec and execfile allow users to pass in plain dicts to be used for locals and/or globals.
- Previous message: [Python-Dev] Accessing globals without dict lookup
- Next message: [Python-Dev] Accessing globals without dict lookup
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]