Important data type of python dictionary

First, the initial dictionary

1, container data types previously learned only list, then the list it enough? What are the disadvantages he do?

  a, the list can store large amounts of data type, but if the data is too big, he's slower query

  B, only a list stored in the order, between the data associated with not strong.

For the above shortcomings, the need to introduce another type of container data types, to solve the above problem, this is the dict dictionary

2, the data types can be classified according to different angles, here classified according to the data type of the variable and immutable

  Immutable (hashable) data types: int, str, bool, tuple.

  Variable (not hashed) data types: list, dict, set.

3, the dictionary is a map type python language, he is enclosed in {}, the content of which is stored in the form of key-value pairs

  key: immutable (hashable) data types. And the key is unique, not repeated.

  value: arbitrary data (int, str, bool, tuple, list, dict, set), including instantiating objects.

4, version issue

  Before python3.5 version of the dictionary are unordered

  After python3.6 version, the dictionary is sorted (i.e., the first data are arranged sequentially inserted) in the order of the first built dictionary

5, Dictionary of shortcomings:

  Huge memory consumption

6, related operations

  python basic data types

Guess you like

Origin www.cnblogs.com/youhongliang/p/12235765.html