Lists The items of a list are arbitrary Python objects. Lists are formed by placing a comma-separated list of expressions in square brackets. (Note that there are no special cases needed to form lists of length 0 or 1.) 

Byte Arrays A bytearray object is a mutable array. They are created by the built-in bytearray() constructor. Aside from being mutable (and hence unhashable), byte arrays otherwise provide the same interface and functionality as immutable$_{bytes}$objects. 

The extension module array provides an additional example of a mutable sequence type, as does the collections module. 

Set types These represent unordered, finite sets of unique, immutable objects. As such, they cannot be indexed by any subscript. However, they can be iterated over, and the built-in function$_{len()}$ returns the number of items in a set. Common uses for sets are fast membership testing, removing duplicates from a sequence, and computing mathematical operations such as intersection, union, difference, and symmetric difference. 

For set elements, the same immutability rules apply as for dictionary keys. Note that numeric types obey the normal rules for numeric comparison: if two numbers compare equal (e.g., 1 and 1.0 ), only one of them can be contained in a set. 

There are currently two intrinsic set types: 

Sets These represent a mutable set. They are created by the built-in set() constructor and can be modified afterwards by several methods, such as add() . 

Frozen sets These represent an immutable set. They are created by the built-in$_{frozenset()}$ constructor. As a frozenset is immutable and hashable , it can be used again as an element of another set, or as a dictionary key. 

Mappings These represent finite sets of objects indexed by arbitrary index sets. The subscript notation$_{a[k]}$ selects the item indexed by$_{k}$ from the mapping$_{a}$; this can be used in expressions and as the target of assignments or $_{del}$statements. The built-in function$_{len()}$ returns the number of items in a mapping. 

There is currently a single intrinsic mapping type: 

Dictionaries These represent finite sets of objects indexed by nearly arbitrary values. The only types of values not acceptable as keys are values containing lists or dictionaries or other mutable types that are compared by value rather than by object identity, the reason being that the efficient implementation of dictionaries requires a key’s hash value to remain constant. Numeric types used for keys obey the normal rules for numeric comparison: if two numbers compare equal (e.g.,$_{1}$and$_{1.0}$ ) then they can be used interchangeably to index the same dictionary entry. 

Dictionaries preserve insertion order, meaning that keys will be produced in the same order they were added sequentially over the dictionary. Replacing an existing key does not change the order, however removing a key and re-inserting it will add it to the end instead of keeping its old place. 

Dictionaries are mutable; they can be created by the$_{{...}}$ notation (see section Dictionary displays ). 

The extension modules$_{dbm.ndbm}$ and$_{dbm.gnu}$ provide additional examples of mapping types, as does the$_{collections}$ module. 

Changed in version 3.7: Dictionaries did not preserve insertion order in versions of Python before 3.6. In CPython 3.6, insertion order was preserved, but it was considered an implementation detail at that time rather than a language guarantee. 

Callable types These are the types to which the function call operation (see section Calls ) can be applied: 

User-defined functions A user-defined function object is created by a function definition (see section Function definitions ). It should be called with an argument list containing the same number of items as the function’s formal parameter list. 

Special attributes: 

