What happens when I create a list, such as c = [1] in python, in terms of name object bindings?

After reading http://www.effbot.org/zone/python-objects.htm I was left with this question:

In python, if it a=1creates an integer object and associates it with a name a, b=[]creates an empty list object and associates it with a name b, which happens when I call, for example. c=[1]?

I assume this creates a list object and associates it with a name c, but how exactly is it processed 1? What does the actual contents of the object list under the hood look like? Does it consist of an integer object or a reference to a "separate" integer object? Can one think, for example, about the c[0]name associated with a list item?

What about the following:

d=1  # creates int(1)-object and binds it to d
e=[d]  # creates list-object and binds it to e, but what happens with d?

Will the contents of the object list (with name e) be a reference to an integer object with a name dor a new integer object?

I think the answer lies in this quote from Mr. Lund from the source mentioned above, but I'm still a little confused:

, . , , .

, : Python; ?, .

+6
1

python, a=1 a, b=[] - b, , , . c=[1]?

c to [1] Python , 1. , , C :

typedef struct {
    PyObject_VAR_HEAD
    PyObject **ob_item;
    Py_ssize_t allocated;
} PyListObject;

, ob_item , PyObject . ob_item , 1.

, , , c [0] , ?

. c[0] Python, 0. , , , C:

Py_INCREF(a->ob_item[i]);
return a->ob_item[i];

:

d=1  # creates int(1)-object and binds it to d
e=[d]  # creates list-object and binds it to e, but what happens with d?

d 1, e 1. d e[0] :

>>> a = 10
>>> b = [a]
>>> id(a) == id(b[0])
True
>>> 

e = [d] Python , , d.

+2

Source: https://habr.com/ru/post/1017353/