Re: [Python-Dev] Scope object (Re: nonlocals() function?)

2010-04-08 Thread Cesare Di Mauro
2010/4/7 Steven D'Aprano st...@pearwood.info On Tue, 6 Apr 2010 04:25:08 pm Cesare Di Mauro wrote: It will certainly. There's MUCH that can be optimized to let CPython squeeze more performance from static analysis (even a gross one) on locals. [...] They are just dummy examples, but

Re: [Python-Dev] Scope object (Re: nonlocals() function?)

2010-04-06 Thread Cesare Di Mauro
2010/4/6 Antoine Pitrou solip...@pitrou.net Greg Ewing greg.ewing at canterbury.ac.nz writes: Maybe it would be better to deprecate globals() and locals() and replace them with another function called something like scope(). It is useful to distinguish between globals (i.e.,

Re: [Python-Dev] Scope object (Re: nonlocals() function?)

2010-04-06 Thread Greg Ewing
Reid Kleckner wrote: If I remember correctly, the exec statement is going away in py3k, and calling exec() with one argument can modify the local scope. I've been kind of wondering what the deal is with exec in py3. I always thought the reason for making exec a statement was so that locals

Re: [Python-Dev] Scope object (Re: nonlocals() function?)

2010-04-06 Thread Cesare Di Mauro
2010/4/6 Greg Ewing greg.ew...@canterbury.ac.nz Cesare Di Mauro wrote: It will certainly. There's MUCH that can be optimized to let CPython squeeze more performance from static analysis (even a gross one) on locals. But can the existing locals() function be implemented in the face of

Re: [Python-Dev] Scope object (Re: nonlocals() function?)

2010-04-06 Thread Tobias Ivarsson
On Tue, Apr 6, 2010 at 11:13 AM, Greg Ewing greg.ew...@canterbury.ac.nzwrote: Reid Kleckner wrote: If I remember correctly, the exec statement is going away in py3k, and calling exec() with one argument can modify the local scope. I've been kind of wondering what the deal is with exec in

Re: [Python-Dev] Scope object (Re: nonlocals() function?)

2010-04-06 Thread Steven D'Aprano
On Tue, 6 Apr 2010 04:25:08 pm Cesare Di Mauro wrote: It will certainly. There's MUCH that can be optimized to let CPython squeeze more performance from static analysis (even a gross one) on locals. [...] They are just dummy examples, but can make it clear how far optimizations can go with

[Python-Dev] Scope object (Re: nonlocals() function?)

2010-04-05 Thread Greg Ewing
Antoine Pitrou wrote: Steve Bonner pythonsteve at gmail.com writes: What do we think of adding a built-in nonlocals() function that would be similar to globals() and locals()? These scopes don't have parallel capabilities: Maybe it would be better to deprecate globals() and locals() and

Re: [Python-Dev] Scope object (Re: nonlocals() function?)

2010-04-05 Thread Michael Foord
On 06/04/2010 00:37, Greg Ewing wrote: Antoine Pitrou wrote: Steve Bonner pythonsteve at gmail.com writes: What do we think of adding a built-in nonlocals() function that would be similar to globals() and locals()? These scopes don't have parallel capabilities: Maybe it would be better to

Re: [Python-Dev] Scope object (Re: nonlocals() function?)

2010-04-05 Thread Reid Kleckner
On Mon, Apr 5, 2010 at 7:35 PM, Antoine Pitrou solip...@pitrou.net wrote: If you can prove that making locals() (or its replacement) writable doesn't complicate the interpreter core too much, then why not. Otherwise -1 :-) I think writable locals would significantly complicate the job of people