Python built-in dictionary: dict support, Dict full name dictionary, also known as map in other languages, using key-value (Key-value) storage, with extremely fast search speed
Use Help (Dict) to find dict-related function actions
For example: dt = dict (name= ' test ', age=20, score=90)
Special Note: 1, the Order of dict internal storage and key into the order is not related.
2. The Dict key must be an immutable object (Dict calculates the storage location of value based on key, which is known as the hash algorithm, which is the algorithm for calculating position by key)
Dict and List comparison:
Dict: Advantages: Find and insert very fast, not slow with the increase of key
Cons: It takes a lot of memory to waste more memory
List: Cons: Finding and inserting time increases as the element increases
Advantages: Small footprint, less space wasted memory
So Dict is a way of exchanging space for time, using lists and dict to distinguish between specific scenarios
This article is from the "cultivate a Perseverance" blog, please be sure to keep this source http://huangfuligang.blog.51cto.com/9181639/1670303
Python dict and list comparison