1use crate::object::*;
2#[cfg(not(PyPy))]
3use crate::pyport::Py_ssize_t;
4
5#[cfg(not(PyPy))]
6#[repr(C)]
7#[derive(Copy, Clone)]
8pub struct PyListObject {
9 pub ob_base: PyVarObject,
10 pub ob_item: *mut *mut PyObject,
11 pub allocated: Py_ssize_t,
12}
13
14#[cfg(PyPy)]
15pub struct PyListObject {
16 pub ob_base: PyObject,
17}
18
19// skipped _PyList_Extend
20// skipped _PyList_DebugMallocStats
21// skipped _PyList_CAST (used inline below)
22
23/// Macro, trading safety for speed
24#[inline]
25#[cfg(not(PyPy))]
26pub unsafe fn PyList_GET_ITEM(op: *mut PyObject, i: Py_ssize_t) -> *mut PyObject {
27 *(*(op as *mut PyListObject)).ob_item.offset(count:i)
28}
29
30/// Macro, *only* to be used to fill in brand new lists
31#[inline]
32#[cfg(not(PyPy))]
33pub unsafe fn PyList_SET_ITEM(op: *mut PyObject, i: Py_ssize_t, v: *mut PyObject) {
34 *(*(op as *mut PyListObject)).ob_item.offset(count:i) = v;
35}
36
37#[inline]
38#[cfg(not(PyPy))]
39pub unsafe fn PyList_GET_SIZE(op: *mut PyObject) -> Py_ssize_t {
40 Py_SIZE(ob:op)
41}
42