TIL - 24/02/17
2024/02/17
- Python Integer Objects
PyLongObject
로 구현되어있다.
1
2
3
4
5
6
7
8
9
struct PyLongObject { // _longobject
// PyObject_HEAD
/* PyObject_HEAD defines the initial segment of every PyObject. */
Py_ssize_t ob_refcnt;
PyTypeObject *ob_type;
// _PyLongValue long_value;
Py_ssize_t ob_size;
uint32_t ob_digit[1];
};
풀어쓰면 이런 모양
PyObject_HEAD
PyObject ob_base;
- 길이가 변하지 않는 객체를 나타내는 새로운 형을 선언할 때 사용되는 매크로
PyObject
- 모든 python 객체(object)가 갖는 내부의 세부적인 부분.
ob_refcnt
와*ob_type
으로 이루어졌다.ob_refcnt
Py_ssize_t ob_refcnt;
- Python의 Garbage Collector가 메모리 관리를 위해 사용하는 참조 횟수이다.
*ob_type
PyTypeObject *ob_type;
- Python의 객체 type을 가리키는 주소(포인터)
This post is licensed under CC BY 4.0 by the author.