来自编程语言语用学,斯科特
Object lifetimes generally correspond to one of three principal storage allocation mechanisms, used to manage the object’s space:
Static objects are given an absolute address that is retained throughout the program’s execution.
Stack objects are allocated and deallocated in last-in, first-out order, usually in conjunction with subroutine calls and returns.
- Heap objects may be allocated and deallocated at arbitrary times. They require a more general (and expensive) storage management algorithm.
C语言有静态对象、堆栈对象和堆对象。在
Python有静态对象、堆栈对象和堆对象吗?在
我看到了in another postCPython分配堆上的所有对象。这是否意味着Python中的所有对象都是堆对象?在
但是Python也有静态方法。Python中的静态方法是静态对象吗?在
谢谢。在
Python对象大多是堆对象,但是在CPython中有一些特殊的PyObject singleton值在C中是static,但这是实现细节。例如,通常的内置类型具有静态存储持续时间。据我所知,没有堆栈(Python)对象。在
静态存储持续时间与静态方法完全无关。在
相关问题 更多 >
编程相关推荐