python use the object model to store data, which means that a value of any type is constructed as an object. All python objects have three attributes: Identity ID, type, and value.
Identity ID : unique identity, you can use the built-in function ID () This value can be considered to be the memory address of the object. The comparison of object identities can be done by operator is or is not, to determine if they point to (reference) the same object, here is an interesting example:
>>> a = 1>>> b = 1>>> c = 1000>>> D = 1000>>> A is btrue>>> c is dFa Lse>>> ID (a), id (b), ID (c), id (d) (11258984, 11258984, 12386056, 11594792)
can be seen,aand thebpoint to the same object, butCand theDbut different, why is this? This is because the integer object and the string object are immutable objects,pythoncache them very efficiently, but the integer object caches only simple integers, as in the example above0, +Will not be cached.
Type: the type of an object determines what type of value the object can hold, what kind of action it can take, and what rules it can follow to use the built-in functiontype ()Viewpythontype of object, or you can use theisinstance (), inpythontypes are also object base data types include numbers, integers, booleans, long integers, floating-point, plural, string, list, tuple, and dictionary, and some other built-in types, which are types,None, files, collections, functions, modules, and classes, in addition to some internal types, i.e. code, frames, trace records, slices (step slices, multidimensional slices, omit slices), omitted (omitting an object has a unique nameellipsis),Xrange(isRange ()supplement).
value: The data item represented by the object. Comparison of object values you can also use the cmp () built-in function in addition to some common operators .
The types mentioned above can be categorized according to three different models: the storage model, the update model, and the access model.
There are two types of storage models-
Atomic type: Numeric, String.
Container type: list, tuple, dictionary.
There are two types of update models-
Mutable type: list, dictionary.
Immutable types: Numbers, strings, and tuples.
There are three types of access models-
Direct access: Numbers.
Sequential access: strings, lists, and tuples.
Map access: Dictionary.
What is a Python object