Does dictionary's clear() method delete all the item related objects from memory?

后端 未结 7 1572
梦毁少年i
梦毁少年i 2020-12-23 17:26

If a dictionary contains mutable objects or objects of custom classes (say a queryset, or a even a DateTime), then will calling clear() on the dictionary delet

相关标签:
7条回答
  • 2020-12-23 17:52

    It is the same as calling del d['foo'] - it just deletes the entries, but it does not affect the keys or values themselves.

    Of course, they may then become garbage collectible if there are no other references to them.

    0 讨论(0)
提交回复
热议问题