1

I am trying to find out a variable size in memory. So I tried using sys.getsizeof(var) but I keep getting an error:

AttributeError: 'module' object has no attribute 'getsizeof'

I searched for solutions online but still no luck. I also re-installed the Python version that I am using and I am still having the same problem.

jonrsharpe
  • 115,751
  • 26
  • 228
  • 437
  • 3
    *Which* version of Python? Per [the docs](https://docs.python.org/2/library/sys.html#sys.getsizeof), `getsizeof` was new in 2.6. – jonrsharpe Aug 13 '14 at 08:41
  • as I have found out just now, it seems it only works on version 2.6 and higher. I am using 2.5.4. Is there a way to get the size of the variable in this version? Many Thanks – yatsuko kasuka Aug 13 '14 at 08:54
  • 1
    A better question might be - why do you think you need to know the variable size in memory? (Also: why are you still using the nearly-six-years-old 2.5.4?) That being said, there are some answers for earlier versions in http://stackoverflow.com/q/449560/3001761. – jonrsharpe Aug 13 '14 at 09:03
  • I am trying to check the size of an object that goes with the outgoing UDP frame. I am using 2.5.4 because of the compatibility issue that I am working on at the moment. – yatsuko kasuka Aug 13 '14 at 09:09

0 Answers0