[IronPython] Updating globals()

Dino Viehland dinov at exchange.microsoft.com
Tue Mar 28 15:09:54 PST 2006


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: users-bounces at lists.ironpython.com [mailto:users-bounces at lists.ironpython.com] 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: users-bounces at lists.ironpython.com [mailto:users-bounces at lists.ironpython.com] 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 at lists.ironpython.com
http://lists.ironpython.com/listinfo.cgi/users-ironpython.com


More information about the users mailing list