cpython/Objects/structseq.c

/* Implementation helper: a struct that looks like a tuple.
   See timemodule and posixmodule for example uses.

   The structseq helper is considered an internal CPython implementation
   detail.  Docs for modules using structseqs should call them
   "named tuples" (be sure to include a space between the two
   words and add a link back to the term in Docs/glossary.rst).
*/

#include "Python.h"
#include "pycore_initconfig.h"    // _PyStatus_OK()
#include "pycore_modsupport.h"    // _PyArg_NoPositional()
#include "pycore_object.h"        // _PyObject_GC_TRACK()
#include "pycore_structseq.h"     // PyStructSequence_InitType()
#include "pycore_tuple.h"         // _PyTuple_FromArray()

static const char visible_length_key[] =;
static const char real_length_key[] =;
static const char unnamed_fields_key[] =;
static const char match_args_key[] =;

/* Fields with this name have only a field index, not a field name.
   They are only allowed for indices < n_visible_fields. */
const char * const PyStructSequence_UnnamedField =;

static Py_ssize_t
get_type_attr_as_size(PyTypeObject *tp, PyObject *name)
{}

#define VISIBLE_SIZE(op)
#define VISIBLE_SIZE_TP(tp)
#define REAL_SIZE_TP(tp)
#define REAL_SIZE(op)

#define UNNAMED_FIELDS_TP(tp)
#define UNNAMED_FIELDS(op)

static Py_ssize_t
get_real_size(PyObject *op)
{}

PyObject *
PyStructSequence_New(PyTypeObject *type)
{}

void
PyStructSequence_SetItem(PyObject *op, Py_ssize_t index, PyObject *value)
{}

PyObject*
PyStructSequence_GetItem(PyObject *op, Py_ssize_t index)
{}


static int
structseq_traverse(PyStructSequence *obj, visitproc visit, void *arg)
{}

static void
structseq_dealloc(PyStructSequence *obj)
{}

/*[clinic input]
class structseq "PyStructSequence *" "NULL"
[clinic start generated code]*/
/*[clinic end generated code: output=da39a3ee5e6b4b0d input=9d781c6922c77752]*/

#include "clinic/structseq.c.h"

/*[clinic input]
@classmethod
structseq.__new__ as structseq_new
    sequence as arg: object
    dict: object(c_default="NULL") = {}
[clinic start generated code]*/

static PyObject *
structseq_new_impl(PyTypeObject *type, PyObject *arg, PyObject *dict)
/*[clinic end generated code: output=baa082e788b171da input=90532511101aa3fb]*/
{}


static PyObject *
structseq_repr(PyStructSequence *obj)
{}


static PyObject *
structseq_reduce(PyStructSequence* self, PyObject *Py_UNUSED(ignored))
{}


static PyObject *
structseq_replace(PyStructSequence *self, PyObject *args, PyObject *kwargs)
{}

static PyMethodDef structseq_methods[] =;

static Py_ssize_t
count_members(PyStructSequence_Desc *desc, Py_ssize_t *n_unnamed_members) {}

static int
initialize_structseq_dict(PyStructSequence_Desc *desc, PyObject* dict,
                          Py_ssize_t n_members, Py_ssize_t n_unnamed_members) {}

static PyMemberDef *
initialize_members(PyStructSequence_Desc *desc,
                   Py_ssize_t n_members, Py_ssize_t n_unnamed_members)
{}


static void
initialize_static_fields(PyTypeObject *type, PyStructSequence_Desc *desc,
                         PyMemberDef *tp_members, Py_ssize_t n_members,
                         unsigned long tp_flags)
{}

static int
initialize_static_type(PyTypeObject *type, PyStructSequence_Desc *desc,
                       Py_ssize_t n_members, Py_ssize_t n_unnamed_members) {}

int
_PyStructSequence_InitBuiltinWithFlags(PyInterpreterState *interp,
                                       PyTypeObject *type,
                                       PyStructSequence_Desc *desc,
                                       unsigned long tp_flags)
{}

int
PyStructSequence_InitType2(PyTypeObject *type, PyStructSequence_Desc *desc)
{}

void
PyStructSequence_InitType(PyTypeObject *type, PyStructSequence_Desc *desc)
{}


/* This is exposed in the internal API, not the public API.
   It is only called on builtin static types, which are all
   initialized via _PyStructSequence_InitBuiltinWithFlags(). */

void
_PyStructSequence_FiniBuiltin(PyInterpreterState *interp, PyTypeObject *type)
{}


PyTypeObject *
_PyStructSequence_NewType(PyStructSequence_Desc *desc, unsigned long tp_flags)
{}


PyTypeObject *
PyStructSequence_NewType(PyStructSequence_Desc *desc)
{}