One option is to define __slots__ on your classes and not include __dict__ in 
the list of slots.  This will limit the attributes you can store on the object 
and the objects will all be stored in an array instead of a dictionary.  
__slots__ should include each attribute you want to be able to set:

class object(object):
                __slots__ = ['a', 'b', 'c']



From: [email protected] 
[mailto:[email protected]] On Behalf Of Patrick DeschĂȘnes
Sent: Thursday, September 17, 2009 1:00 PM
To: [email protected]
Subject: [IronPython] Many small objects and memory footprint

Hello,

I'm currently using IronPython to manage a big tree of small objects.  
Everything works as fine but the memory usage is really huge (about 6x greater 
than the same program writtent in C#).  I assumed the memory usage would be 
greater in dynamic language than in C#.  Since I really need to have a small 
memory footprint, what strategy should I use to keep the memory usage low.

NOTE:  There's many classes already written in python and I would really like 
to keep using python, but I'm open to suggestion.

Patrick
_______________________________________________
Users mailing list
[email protected]
http://lists.ironpython.com/listinfo.cgi/users-ironpython.com

Reply via email to