Re: [IronPython] Updating globals()

2006-03-29 Thread J. Merrill
Not all attributes can be stored as static variables, or you couldn't add new 
ones at runtime.  So there must also be a dictionary in the CustomDict subclass 
-- right?  Are the only attributes that are made into statics the all modules 
have these names?  (That is, the names I would find if I create a new Module 
object and examine it?)  Or does make the names assigned in the __init__ method 
static as well?

What happens if one of the static-var-stored dictionary entries gets removed 
from one of these CustomDict subclasses?  Is there a value that can be stored 
in the corresponding static variable that means do a name lookup within 
superclasses to find this when you get this value (and raise a NameError if 
it's not found) so that removing an entry will work correctly?  (If retrieving 
one of the static-var-stored values is really just ldsfld / stsfld, with no 
check for whether the value returned means there's no entry here, can things 
work right?)

Maybe I should do some testing -- but it might not be fruitful until the 
just-discovered bug is fixed.

At 06:09 PM 3/28/2006, Dino Viehland wrote (in part)
When you are running from a module we generate a module type which is a 
subclass of CustomDict.  That CustomDict stores the field values as static 
variables which allows quicker access than requiring a dictionary lookup each 
time through (in particular the module gets to just do a ldsfld / stsfld in IL 
to get the value, but setting the value from outside of the module is still 
relatively expensive).
[snip]


J. Merrill / Analytical Software Corp

___
users mailing list
users@lists.ironpython.com
http://lists.ironpython.com/listinfo.cgi/users-ironpython.com


Re: [IronPython] Updating globals()

2006-03-28 Thread J. Merrill
What makes running from file work differently than the console?  Are there 
possibly other similar issues?  (Failing from the console while working from 
file is the more common issue, isn't it, in CPython?)

At 11:30 AM 3/27/2006, Dino Viehland wrote
Thanks for the bug report Seo. I can repro this on our current builds and have 
filed the bug.  I think we'll be able to get this one fixed for beta 5.

Do you want to help develop Dynamic languages on CLR? 
(http://members.microsoft.com/careers/search/details.aspx?JobID=6D4754DE-11F0-45DF-8B78-DC1B43134038)
-Original Message-
From: [EMAIL PROTECTED] [mailto:[EMAIL PROTECTED] On Behalf Of Sanghyeon Seo
Sent: Monday, March 27, 2006 12:26 AM
To: Discussion of IronPython
Subject: [IronPython] Updating globals()

Updating module-level globals() raises AttributeError.

vars = {'a': 1, 'b': 2}
globals().update(vars)
print a, b

Seo Sanghyeon


J. Merrill / Analytical Software Corp

___
users mailing list
users@lists.ironpython.com
http://lists.ironpython.com/listinfo.cgi/users-ironpython.com


Re: [IronPython] Updating globals()

2006-03-28 Thread Dino Viehland
When you are running from a module we generate a module type which is a 
subclass of CustomDict.  That CustomDict stores the field values as static 
variables which allows quicker access than requiring a dictionary lookup each 
time through (in particular the module gets to just do a ldsfld / stsfld in IL 
to get the value, but setting the value from outside of the module is still 
relatively expensive).

At the console the dictionary is really just a standard dict object, so of 
course that one works!

It turns out that we were missing the update method on the custom dict classes.

We currently run our entire test suite through 2 modes: one mode is generate as 
snippets mode which is the same as if you were typing code in at the console.  
This mode is optimized to not create new types (which the CLR cannot garbage 
collection).  This is also the mode that gets used when executing code 
dynamically via eval.  The other is our normal mode where imported modules get 
compiled into real types.   This mode is optimized for performance.

We introduced the two-sets of test passes after the console regressions in beta 
1.  In this case we're just missing some coverage of doing update on the 
dictionary returned from globals() so we hadn't seen it.

The final thing for us to review is making sure our custom dictionaries have 
ALL the functionality that our normal dictionaries have, and of course we'll do 
that as part of fixing this bug (and put in place a test case to catch any 
future regressions).


Do you want to help develop Dynamic languages on CLR? 
(http://members.microsoft.com/careers/search/details.aspx?JobID=6D4754DE-11F0-45DF-8B78-DC1B43134038)

-Original Message-
From: [EMAIL PROTECTED] [mailto:[EMAIL PROTECTED] On Behalf Of J. Merrill
Sent: Tuesday, March 28, 2006 2:59 PM
To: Discussion of IronPython
Subject: Re: [IronPython] Updating globals()

What makes running from file work differently than the console?  Are there 
possibly other similar issues?  (Failing from the console while working from 
file is the more common issue, isn't it, in CPython?)

At 11:30 AM 3/27/2006, Dino Viehland wrote
Thanks for the bug report Seo. I can repro this on our current builds and have 
filed the bug.  I think we'll be able to get this one fixed for beta 5.

Do you want to help develop Dynamic languages on CLR? 
(http://members.microsoft.com/careers/search/details.aspx?JobID=6D4754DE-11F0-45DF-8B78-DC1B43134038)
-Original Message-
From: [EMAIL PROTECTED] [mailto:[EMAIL PROTECTED] On Behalf Of Sanghyeon Seo
Sent: Monday, March 27, 2006 12:26 AM
To: Discussion of IronPython
Subject: [IronPython] Updating globals()

Updating module-level globals() raises AttributeError.

vars = {'a': 1, 'b': 2}
globals().update(vars)
print a, b

Seo Sanghyeon


J. Merrill / Analytical Software Corp

___
users mailing list
users@lists.ironpython.com
http://lists.ironpython.com/listinfo.cgi/users-ironpython.com
___
users mailing list
users@lists.ironpython.com
http://lists.ironpython.com/listinfo.cgi/users-ironpython.com


Re: [IronPython] Updating globals()

2006-03-27 Thread Sanghyeon Seo
2006/3/27, Rene Olsthoorn [EMAIL PROTECTED]:
 On Windows XP, it runs without a problem.

Strange, I can reproduce this on Windows XP too.

Seo Sanghyeon
___
users mailing list
users@lists.ironpython.com
http://lists.ironpython.com/listinfo.cgi/users-ironpython.com


Re: [IronPython] Updating globals()

2006-03-27 Thread Dino Viehland
Thanks for the bug report Seo. I can repro this on our current builds and have 
filed the bug.  I think we'll be able to get this one fixed for beta 5.

Do you want to help develop Dynamic languages on CLR? 
(http://members.microsoft.com/careers/search/details.aspx?JobID=6D4754DE-11F0-45DF-8B78-DC1B43134038)
-Original Message-
From: [EMAIL PROTECTED] [mailto:[EMAIL PROTECTED] On Behalf Of Sanghyeon Seo
Sent: Monday, March 27, 2006 12:26 AM
To: Discussion of IronPython
Subject: [IronPython] Updating globals()

Updating module-level globals() raises AttributeError.

vars = {'a': 1, 'b': 2}
globals().update(vars)
print a, b

Seo Sanghyeon
___
users mailing list
users@lists.ironpython.com
http://lists.ironpython.com/listinfo.cgi/users-ironpython.com
___
users mailing list
users@lists.ironpython.com
http://lists.ironpython.com/listinfo.cgi/users-ironpython.com


Re: [IronPython] Updating globals()

2006-03-27 Thread Dino Viehland
Did you run it at the console or from a file you imported?

IronPython will actually use different underlying CLR dictionary objects 
depending on how the code gets compiled (which is the reason why this compiles 
in one spot but not another).

Do you want to help develop Dynamic languages on CLR? 
(http://members.microsoft.com/careers/search/details.aspx?JobID=6D4754DE-11F0-45DF-8B78-DC1B43134038)

-Original Message-
From: [EMAIL PROTECTED] [mailto:[EMAIL PROTECTED] On Behalf Of Rene Olsthoorn
Sent: Monday, March 27, 2006 12:52 AM
To: Discussion of IronPython
Subject: Re: [IronPython] Updating globals()

Hello Seo,

On Windows XP, it runs without a problem.

Greets, Rene Olsthoorn.

On 3/27/06, Sanghyeon Seo [EMAIL PROTECTED] wrote:
 Updating module-level globals() raises AttributeError.

 vars = {'a': 1, 'b': 2}
 globals().update(vars)
 print a, b

 Seo Sanghyeon
 ___
 users mailing list
 users@lists.ironpython.com
 http://lists.ironpython.com/listinfo.cgi/users-ironpython.com

___
users mailing list
users@lists.ironpython.com
http://lists.ironpython.com/listinfo.cgi/users-ironpython.com
___
users mailing list
users@lists.ironpython.com
http://lists.ironpython.com/listinfo.cgi/users-ironpython.com