Table of Content
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 |
''' ''' @Author: Jedi.XL @Email: xiangyangan@gmail.com @Created Time: 5:08:05 PM, Sep 11, 2019 @Github: https://github.com/jediL @Website:www.tundrazone.com ------------ 苔原带 ------------ ''' ''' import sys ls = [] dic = {} print("Empty items") print("--------------------") print(f"size of ls: {sys.getsizeof(ls)}") print(f"size of dic: {sys.getsizeof(dic)}") ls = [1, "a", 2, "b"] dic = {'a': 1, 'b': 2} print("Items not empty") print("----------------------") print(f"size of ls: {sys.getsizeof(ls)}") print(f"size of dic: {sys.getsizeof(dic)}") ls.clear() dic.clear() print("After clear the item") print("------------------------") print(f"size of ls: {sys.getsizeof(ls)}") print(f"size of dic: {sys.getsizeof(dic)}") ''' Empty items -------------------- size of ls: 64 size of dic: 240 Items not empty ---------------------- size of ls: 96 size of dic: 240 After clear the item ------------------------ size of ls: 64 size of dic: 72 ''' |