[IronPython] Performance of dir

Curt Hagenlocher curt at hagenlocher.org
Sun May 24 14:59:48 CEST 2009


The first time you do a dir() of Form, we have to use Reflection to
introspect
- every member on Form
- every member on ContainerControl
- every member on ScrollableControl
- every member on Control
- every member on Component
(aka the inheritance hierarchy of Form :D )

After that, the members are all cached and subsequent access should be quite
fast.

On Sat, May 23, 2009 at 4:47 PM, Michael Foord <fuzzyman at voidspace.org.uk>wrote:

> Michael Foord wrote:
>
>> Hello all,
>>
>> On IronPython 2.0.1 the last line of this code takes ~4 seconds the first
>> time it is executed:
>>
>> >>> import clr
>> >>> clr.AddReference('System.Windows.Forms')
>> >>> from System.Windows.Forms import *
>> >>> dir(Form)
>>
>> Form.__dict__.keys() (which for a .NET type is equivalent) takes ~1 second
>> or less. What extra work is dir doing? (Is it pulling in the xml
>> docstrings?)
>>
>>
> Actually they're not equivalent, my bad:
>
> >>> len(Form.__dict__)
> 287
> >>> len(dir(Form))
> 540
>
> Michael
>
>
>  Thanks
>>
>> Michael
>>
>>
>
> --
> http://www.ironpythoninaction.com/
> http://www.voidspace.org.uk/blog
>
>
> _______________________________________________
> Users mailing list
> Users at lists.ironpython.com
> http://lists.ironpython.com/listinfo.cgi/users-ironpython.com
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.python.org/pipermail/ironpython-users/attachments/20090524/8183edfa/attachment.html>


More information about the Ironpython-users mailing list