python - python中对二维列表元素的内存引用是否连续?
问题描述
Python 使用内存中对实际元素的引用(即,如果您可能会说的指针)来实现列表。这些引用在内存中是连续的。例子:
# RefX, RefY and RefZ are contiguous memory references to the following elements
list_example = [elementX, elementY, elementZ]
#insert elementS at (index 1) will shift all the next references (RefY and RefZ in this
case) in the memory (assume each ref is 8 bit size)
list_example = [elementX, elementS, elementY, elementZ]
#Therefore insert operation time complexity is O(N)
我的问题是:
如果是二维列表:如果我将一个元素附加到第一个列表的末尾:
list_of_lists[0].append(item)
这种情况会导致内存中第二个和第三个列表中元素的引用发生变化吗?
我的主要观点:我问是因为我想知道在追加或弹出的情况下,就时间复杂度而言,实现三个堆栈的列表(作为列表列表)是否是昂贵的操作?
解决方案
推荐阅读
- c - 错误:在 'void' 之前需要 '='、','、';'、'asm' 或 '__attribute__':弱大小写
- javascript - Chartkick 未在 heroku 中加载,但在本地工作
- reactjs - 使用 React +JWT+Express 进行用户管理和密钥共享
- tinymce - tinyMCE 编辑器将本地化路径设置为上传图像的 src
- apache-spark-sql - Spark 连接 - 保存为数据帧或分区配置单元表
- javascript - 在 NodeJS 中传递图像文件参数
- java - 设置和获取 NdefRecord ID
- javascript - 在页面准备好之前动态加载 WebComponents Polyfill
- javascript - 映射对象并将键推送到 ES6 中的值
- informatica-cloud - Informatica Cloud - 来自 dat 文件的空字符问题