Repository: numpy/numpy
File: numpy/_core/src/multiarray/npy_static_data.c (C)

Code before:

    // default_truediv_type_tup
    PyArray_Descr *tmp = PyArray_DescrFromType(NPY_DOUBLE);
    npy_static_pydata.default_truediv_type_tup =
            PyTuple_Pack(3, tmp, tmp, tmp);
    Py_DECREF(tmp);
    if (npy_static_pydata.default_truediv_type_tup == NULL) {
        return -1;
    }

    npy_static_pydata.kwnames_is_copy = Py_BuildValue("(s)", "copy");
    if (npy_static_pydata.kwnames_is_copy == NULL) {
        return -1;
    }

    npy_static_pydata.one_obj = PyLong_FromLong((long) 1);
    if (npy_static_pydata.one_obj == NULL) {
        return -1;
    }

    npy_static_pydata.zero_obj = PyLong_FromLong((long) 0);
    if (npy_static_pydata.zero_obj == NULL) {
        return -1;
    }

    npy_static_pydata.call_kwnames =
            Py_BuildValue("(sss)", "dl_device", "copy", "max_version");
    if (npy_static_pydata.call_kwnames == NULL) {
        return -1;
    }

    npy_static_pydata.dl_cpu_device_tuple = Py_BuildValue("(i,i)", 1, 0);
    if (npy_static_pydata.dl_cpu_device_tuple == NULL) {
        return -1;
    }

    npy_static_pydata.max_version = Py_BuildValue("(i,i)", 1, 0);
    if (npy_static_pydata.max_version == NULL) {
        return -1;
    }

    /*
     * Initialize contents of npy_static_cdata struct
     *
     * Note that some entries are initialized elsewhere. Care
     * must be taken to ensure all entries are initialized during
     * module initialization and immutable thereafter.
     *
     * This struct holds global static caches. These are set
     * up this way for performance reasons.
     */

Review comment (suggestion):
should maybe call all of these `(dlpack|dl)_call_kwnames`, but doens't matter too much.

Code after:

    // default_truediv_type_tup
    PyArray_Descr *tmp = PyArray_DescrFromType(NPY_DOUBLE);
    npy_static_pydata.default_truediv_type_tup =
            PyTuple_Pack(3, tmp, tmp, tmp);
    Py_DECREF(tmp);
    if (npy_static_pydata.default_truediv_type_tup == NULL) {
        return -1;
    }

    npy_static_pydata.kwnames_is_copy = Py_BuildValue("(s)", "copy");
    if (npy_static_pydata.kwnames_is_copy == NULL) {
        return -1;
    }

    npy_static_pydata.one_obj = PyLong_FromLong((long) 1);
    if (npy_static_pydata.one_obj == NULL) {
        return -1;
    }

    npy_static_pydata.zero_obj = PyLong_FromLong((long) 0);
    if (npy_static_pydata.zero_obj == NULL) {
        return -1;
    }

    npy_static_pydata.dl_call_kwnames =
            Py_BuildValue("(sss)", "dl_device", "copy", "max_version");
    if (npy_static_pydata.dl_call_kwnames == NULL) {
        return -1;
    }

    npy_static_pydata.dl_cpu_device_tuple = Py_BuildValue("(i,i)", 1, 0);
    if (npy_static_pydata.dl_cpu_device_tuple == NULL) {
        return -1;
    }

    npy_static_pydata.dl_max_version = Py_BuildValue("(i,i)", 1, 0);
    if (npy_static_pydata.dl_max_version == NULL) {
        return -1;
    }

    /*
     * Initialize contents of npy_static_cdata struct
     *
     * Note that some entries are initialized elsewhere. Care
     * must be taken to ensure all entries are initialized during
     * module initialization and immutable thereafter.
     *
     * This struct holds global static caches. These are set
     * up this way for performance reasons.
     */