Alex Hoffman

Perspective on development, management and technology

Syndication

News

    Subscribe

    IASA Member

Number of Types/Methods in IronPython

Thomas and Oren recently showed a couple of scripts in PowerShell and Boo respectively that count the number of types and methods in mscorlib.

Here is one possible implementation in IronPython ...

import System
typeCount = methodCount = 0
mscorlib = System.Type.GetType('System.Object').Assembly
for t in mscorlib.GetTypes():
    typeCount += 1
    methodCount += t.GetMethods().Length
print "Types: %s | Methods: %s" % (typeCount, methodCount)

On my system (Vista) this script will output ...

Types: 2318 | Methods: 27677

I wonder, is there a more efficient way to implement this in IronPython?

Published Tuesday, June 05, 2007 11:20 AM by Alex Hoffman

Filed under: ,

Comments

# re: Number of Types/Methods in IronPython@ Tuesday, June 05, 2007 8:22 AM

Nice snippet. If it is ok with you, I will post this in the IronPython cookbook ? (Or you could do it?)

Michael Foord

P.S. http://www.ironpython.info/

Fuzzyman

# re: Number of Types/Methods in IronPython@ Tuesday, June 05, 2007 1:42 PM

Here is another implementation. import System mscorlib = System.Type.Assembly.GetValue(System.Object) types = mscorlib.GetTypes() typecount = len(types) methodcount = sum(len(t.GetMethods()) for t in types) print 'Types %d, Methods %d' % (typecount, methodcount)

Seo Sanghyeon

# re: Number of Types/Methods in IronPython@ Sunday, June 17, 2007 9:38 PM

@Michael - sure it's OK.   I did have a look at posting it myself at ironpython.info, but wasn't sure where it should go.

Alex Hoffman

# http://ironpython-urls.blogspot.com/2007/06/number-of-typesmethods-in-mscorlib.html@ Sunday, June 17, 2007 10:17 PM

TrackBack