Skip to main content

You are not logged in. Your edit will be placed in a queue until it is peer reviewed.

We welcome edits that make the post easier to understand and more valuable for readers. Because community members review edits, please try to make the post substantially better than how you found it, for example, by fixing grammar or adding additional resources and hyperlinks.

Required fields*

7
  • thanks very much, I tried that and memory usage became about 1.5 GBs(originally 8GBs). but as I said in the comments, the equivalent C program should take about 300MBs. it means that python takes 5 times more memory. Commented Jan 8, 2015 at 0:10
  • The size of the normal class should really include the size of its __dict__ as well. eg. sys.getsizeof(n) + sys.getsizeof(vars(n)). getsizeof doesn't count size of the dict as its a separate object. Commented Jan 8, 2015 at 0:13
  • @Farzam Well in Python everything is object, including classes, integers etc. Though that's not the case with C/C++. Commented Jan 8, 2015 at 0:23
  • @AshwiniChaudhary I know, but even if you use class in C++, there is not much noticeable difference(compared to the difference with python). So what does python store in these extra memories? Commented Jan 8, 2015 at 0:26
  • @Dunes Oh! yes, and size of __slots__ in case of the second one. Commented Jan 8, 2015 at 0:39