python - Python中的变量存放在哪里?

标签 python memory-management

<分区>

在C++中,局部变量存储在栈中,而new操作符创建的数据存储在堆中。那么,Python 中的变量呢?它们存储在哪里?

最佳答案

复制自 Python documentation :

Memory management in Python involves a private heap containing all Python objects and data structures. The management of this private heap is ensured internally by the Python memory manager. The Python memory manager has different components which deal with various dynamic storage management aspects, like sharing, segmentation, preallocation or caching.

关于python - Python中的变量存放在哪里?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/17764997/

相关文章:

python - 我可以在构造函数方法之外声明 Python 类字段吗?

python - 类必须是一个对象吗?它可以是一个 Action 吗?

linux - linux内核中的大尺寸kmalloc kmalloc

python-3.x - 为什么 python 字符串连接最省内存?

javascript - jQuery 对象内存大小

Python 打印函数中的括号

python - 以 n 行作为输入并在列中的总和等于 n 时返回列名称的函数

c++ - 嵌套容器的自定义分配器

python - 将 UUID 添加到 pandas

data-structures - 栈和堆是什么以及在哪里?