Back to home page

EIC code displayed by LXR

 
 

    


File indexing completed on 2025-01-18 10:06:47

0001 #ifndef Py_INTERNAL_TUPLE_H
0002 #define Py_INTERNAL_TUPLE_H
0003 #ifdef __cplusplus
0004 extern "C" {
0005 #endif
0006 
0007 #ifndef Py_BUILD_CORE
0008 #  error "this header requires Py_BUILD_CORE define"
0009 #endif
0010 
0011 #include "tupleobject.h"   /* _PyTuple_CAST() */
0012 
0013 
0014 /* runtime lifecycle */
0015 
0016 extern PyStatus _PyTuple_InitGlobalObjects(PyInterpreterState *);
0017 extern void _PyTuple_Fini(PyInterpreterState *);
0018 
0019 
0020 /* other API */
0021 
0022 // PyTuple_MAXSAVESIZE - largest tuple to save on free list
0023 // PyTuple_MAXFREELIST - maximum number of tuples of each size to save
0024 
0025 #if defined(PyTuple_MAXSAVESIZE) && PyTuple_MAXSAVESIZE <= 0
0026    // A build indicated that tuple freelists should not be used.
0027 #  define PyTuple_NFREELISTS 0
0028 #  undef PyTuple_MAXSAVESIZE
0029 #  undef PyTuple_MAXFREELIST
0030 
0031 #elif !defined(WITH_FREELISTS)
0032 #  define PyTuple_NFREELISTS 0
0033 #  undef PyTuple_MAXSAVESIZE
0034 #  undef PyTuple_MAXFREELIST
0035 
0036 #else
0037    // We are using a freelist for tuples.
0038 #  ifndef PyTuple_MAXSAVESIZE
0039 #    define PyTuple_MAXSAVESIZE 20
0040 #  endif
0041 #  define PyTuple_NFREELISTS PyTuple_MAXSAVESIZE
0042 #  ifndef PyTuple_MAXFREELIST
0043 #    define PyTuple_MAXFREELIST 2000
0044 #  endif
0045 #endif
0046 
0047 struct _Py_tuple_state {
0048 #if PyTuple_NFREELISTS > 0
0049     /* There is one freelist for each size from 1 to PyTuple_MAXSAVESIZE.
0050        The empty tuple is handled separately.
0051 
0052        Each tuple stored in the array is the head of the linked list
0053        (and the next available tuple) for that size.  The actual tuple
0054        object is used as the linked list node, with its first item
0055        (ob_item[0]) pointing to the next node (i.e. the previous head).
0056        Each linked list is initially NULL. */
0057     PyTupleObject *free_list[PyTuple_NFREELISTS];
0058     int numfree[PyTuple_NFREELISTS];
0059 #else
0060     char _unused;  // Empty structs are not allowed.
0061 #endif
0062 };
0063 
0064 #define _PyTuple_ITEMS(op) _Py_RVALUE(_PyTuple_CAST(op)->ob_item)
0065 
0066 extern PyObject *_PyTuple_FromArray(PyObject *const *, Py_ssize_t);
0067 extern PyObject *_PyTuple_FromArraySteal(PyObject *const *, Py_ssize_t);
0068 
0069 
0070 typedef struct {
0071     PyObject_HEAD
0072     Py_ssize_t it_index;
0073     PyTupleObject *it_seq; /* Set to NULL when iterator is exhausted */
0074 } _PyTupleIterObject;
0075 
0076 #ifdef __cplusplus
0077 }
0078 #endif
0079 #endif   /* !Py_INTERNAL_TUPLE_H */