Python中超过1个字节对象的相同内存地址
如果内存地址参考1内存的字节,则如果我将元素附加到该列表,则如何表示“ 139754451527680”的内存地址保持不变?
为了澄清,我了解数组/列表的元素是元素位置的指示
。大于1个字节对象?
如果我们在谈论8个字节对象,只是(内存地址 * 8)吗?
import sys
a = 1
sys.getsizeof(a) # 28 bytes (24 bytes int overhead; 4 bytes integer value)
id(a) # 9788960 ---> 28 memory slot / memory addresses????
If a memory address references 1 byte of memory, how does the memory address of say '139754451527680' for an empty list stay the same if I append elements to that list?
To clarify, I understand that elements of an array/list are pointers to the elements location, etc...
My question is specific to if the memory address is the address of 1 byte of memory, how does the address 'get calculated' for larger than 1 byte objects?
Is it just the (memory address * 8) if we are talking about an 8 byte object?
import sys
a = 1
sys.getsizeof(a) # 28 bytes (24 bytes int overhead; 4 bytes integer value)
id(a) # 9788960 ---> 28 memory slot / memory addresses????
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论