data size

Martin von Loewis loewis at informatik.hu-berlin.de
Fri Nov 9 14:14:21 CET 2001


"harry" <hartanto at telusplanet.net> writes:

> if you put data into dictionary, how do we calculate the data size?

This is very difficult, and I suggest you don't really want to know.

> example:
> 
> dict = {"key1":1,2,3,4; "key2": "hello", [1,2,3]}

This is invalid syntax, I'll assume that you meant

{"key1":[1,2,3,4], "key2": "hello", "key3": [1,2,3]}

> 
> how much is the data structure will cost? how to calculate it?

Notice that dict is now a collection of 11 objects:
- four strings
- four integers: 1,2,3,4
- two lists: [1,2,3,4] and [1,2,3]
- one dictionary

You may think that the integers should be counted twice, but you
actually have the same integer objects in each list.

Do you want the siye of just the dictionary, or of all the objects
together? What Python version? What operating system/microprocessor?
What C library (to account for the overhead of malloc/free).

Regards,
Martin



More information about the Python-list mailing list