I have a ramdrive created through fstab as
tmpfs /mnt/ram tmpfs defaults,size=2048M 0 0
This space filled up to 86% so I deleted some large files.
Now the python view and the linux view differ on this disk usage. It looks like the python view does not account for the deleted files.
>>> from os import system
>>> import psutil
>>> import shutil
>>> cmd = 'du -s /mnt/ram/'
>>> system(cmd)
632 /mnt/ram/
0
>>> psutil.disk_usage('/mnt/ram/')
sdiskusage(total=2147483648, used=1862307840, free=285175808, percent=86.7)
>>> shutil.disk_usage('/mnt/ram/')
usage(total=2147483648, used=1862500352, free=284983296)