# listobject.rs - source
Source of the Rust file `/home/runner/.cargo/registry/src/github.com-1ecc6299db9ec823/pyo3-0.13.2/src/ffi/cpython/listobject.rs`.
Keywords: rust, rustlang, rust-lang

     1
     2
     3
     4
     5
     6
     7
     8
     9
    10
    11
    12
    13
    14
    15
    16
    17
    18
    19
    20
    21
    22
    23
    24
    25
    26
    27
    28
    29
    30
    31

    use crate::ffi::object::*;
    use crate::ffi::pyport::Py_ssize_t;

    #[repr(C)]
    #[derive(Copy, Clone)]
    pub struct PyListObject {
        pub ob_base: PyVarObject,
        pub ob_item: *mut *mut PyObject,
        pub allocated: Py_ssize_t,
    }

    // skipped _PyList_Extend
    // skipped _PyList_DebugMallocStats
    // skipped _PyList_CAST (used inline below)

    /// Macro, trading safety for speed
    #[inline]
    pub unsafe fn PyList_GET_ITEM(op: *mut PyObject, i: Py_ssize_t) -> *mut PyObject {
        *(*(op as *mut PyListObject)).ob_item.offset(i as isize)
    }

    /// Macro, *only* to be used to fill in brand new lists
    #[inline]
    pub unsafe fn PyList_SET_ITEM(op: *mut PyObject, i: Py_ssize_t, v: *mut PyObject) {
        *(*(op as *mut PyListObject)).ob_item.offset(i as isize) = v;
    }

    #[inline]
    pub unsafe fn PyList_GET_SIZE(op: *mut PyObject) -> Py_ssize_t {
        Py_SIZE(op)
    }