[英]How does python lists manage values of different data types?
If I am not wrong, python lists are linked lists, lets say we have a list如果我没记错的话,python 列表是链表,假设我们有一个列表
L =['a',34]
According to my understanding it looks like this根据我的理解,它看起来像这样
_ __ ___ __
|_a|_*| --> |_34|__|
And from C we know that pointer next to 'a' will point to a data type similar to its own, ie in this case a 'char', but how does python here manage to do this从 C 中我们知道,'a' 旁边的指针将指向一个类似于它自己的数据类型,即在这种情况下是一个 'char',但是这里的 python 如何做到这一点
I tried to see the source code it hurt my head, can someone please explain its working in simple words我试图查看源代码,它让我头疼,有人可以用简单的话解释一下它的工作原理吗
Edit: I've been banned from posting after posting this question and I don't understand why编辑:发布这个问题后我被禁止发布,我不明白为什么
I'm not sure, but I think every variable in python is actually stored as a structure, containing datatype and then the raw data.我不确定,但我认为 python 中的每个变量实际上都存储为一个结构,包含数据类型,然后是原始数据。 So behind the scenes every variable is actually of the same type (which is this structure).所以在幕后,每个变量实际上都是相同的类型(就是这个结构)。
https://realpython.com/python-variables/ https://realpython.com/python-variables/
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.