[code.view]

[top] / python / PyMOTW / sys / sys_getsizeof_object.py

     #!/usr/bin/env python
     # encoding: utf-8
     #
     # Copyright (c) 2009 Doug Hellmann All rights reserved.
     #
     """
     """
     #end_pymotw_header
     
     import sys
     
     class WithoutAttributes(object):
         pass
     
     class WithAttributes(object):
         def __init__(self):
             self.a = 'a'
             self.b = 'b'
             return
     
     without_attrs = WithoutAttributes()
     print 'WithoutAttributes:', sys.getsizeof(without_attrs)
     
     with_attrs = WithAttributes()
     print 'WithAttributes:', sys.getsizeof(with_attrs)
     

[top] / python / PyMOTW / sys / sys_getsizeof_object.py

contact | logmethods.com