문제

is there a function in Python which can find out how much memory takes a certain attribute or a variable?

EXAMPLE:

a='ThisTakesSeveralBitesOfMemory'
print(a.memoryTaken())

>> 20 b
도움이 되었습니까?

해결책

You can use sys.getsizeof(). It returns in bytes.

>>> a='ThisTakesSeveralBitesOfMemory'
>>> sys.getsizeof(a)
50
라이센스 : CC-BY-SA ~와 함께 속성
제휴하지 않습니다 StackOverflow
scroll top