DZone

Basis of Dictionaries and Sets

A dictionary is composed of a series of key-value mapping elements. In Python 3.7 +, a dictionary is determined to be ordered, however, before 3.6, a dictionary was disordered. Its length is mutable and elements can be deleted and changed arbitrarily. Compared with lists and tuples, the performance of dictionaries is better, especially for search, add, and delete operations. A dictionary can be completed within a constant time complexity. A set and a dictionary are basically the same, the only difference is that a set has no key-value pairing and is a series of disordered and unique element combinations. 

First, let’s look at the creation of dictionaries and collections. There are usually the following ways;

Source: DZone