Advertisement
Guest User

Untitled

a guest
Sep 10th, 2012
167
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Python 0.51 KB | None | 0 0
  1. Python 2.7.3 (default, Jun 18 2012, 17:45:15)
  2. [GCC 4.5.3] on linux2
  3. Type "help", "copyright", "credits" or "license" for more information.
  4. >>> import sys
  5. >>> import collections
  6. >>> point = collections.namedtuple('Point',['x','y'])
  7. >>> class PointClass(object):
  8. ...     __slots__=['x','y']
  9. ...
  10. >>> sys.getsizeof(point)
  11. 904
  12. >>> sys.getsizeof(PointClass)
  13. 904
  14. >>> inst1 = point(x=1,y=2)
  15. >>> inst2 = PointClass()
  16. >>> inst2.x = 1
  17. >>> inst2.y = 2
  18. >>> sys.getsizeof(inst1)
  19. 72
  20. >>> sys.getsizeof(inst2)
  21. 64
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement