python的list和c的数组有什么区别

Python023

python的list和c的数组有什么区别,第1张

list类似于链表

可以支持多种不同类型,不过python有更快的array模块,和c的数组一样。

array只能是单一类型,而且支持的类型有限,支持的操作方法和list类似

from ctypes import *

class AAA(Structure):

    _fields_ = [("a", c_int),

                ("b", c_int),

                ("c", c_int),

                ("d", c_int),

                ]