how many objects are loaded for hello world?

F

Fredrik Lundh

belred said:
i just read this blog about how many objects (types) are loaded for a
hello world program in C#.

http://blogs.msdn.com/abhinaba/archive/2008/09/15/how-many-types-are-loaded-for-hello-world.aspx

how can you find out how many are loaded for a python program: print
'hello'

types and objects are different things, though. to get an idea of how
much stuff Python loads using upstart, do "python -vv script.py" or add

import sys
print len(sys.modules), "modules"
print sys.modules.keys()

to the end of the script.

to get an idea of how many objects and types that are created at that
point, add

import gc
print len(gc.get_objects()), "objects"
print len(set(map(type, gc.get_objects()))), "types"

this gives me 35 modules (including the gc module), 3219 objects and 26
distinct types -- but the above will miss things, so the true numbers
are a bit higher.

(you might be able to use a debug build to get more detailed information)

</F>
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
473,766
Messages
2,569,569
Members
45,045
Latest member
DRCM

Latest Threads

Top