I have code as below where table data is captured in set(cur)
. Is there any way to find the space occupied by this variable in linux/unix? (Memory or buffer space)
cur.execute("select A , B , C from DeptTable")
dept_entries = set(cur)
cur.execute("select A , B , C from EmployeeTable where EmplName in ('A','B')")
for empl in cur:
if empl in dept_entries:
print(empl, 'Yes')
else:
print(empl, 'No')
I would recommend using sys.getsizeof
:
>>> import sys
>>> sys.getsizeof(dept_entries)
12345
>>> sys.getsizeof(set([1,2,3]))
224
>>> sys.getsizeof(set([1,2,3,4,5]))
736
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With