Memory-usage of dictionary in Python?

前端 未结 3 2095
广开言路
广开言路 2021-01-01 15:44

I am slightly confused when I use the getsizeof method in the sys module for dictionaries. Below I have created a simple dictionary of two strings.

3条回答
  •  误落风尘
    2021-01-01 16:15

    From the PythonDocs

    See recursive sizeof recipe for an example of using getsizeof() recursively to find the size of containers and all their contents.

    So it only counts the overhead, but you can use the function in this link to calculate it for containers like dicts.

提交回复
热议问题