xref: /third_party/python/Include/internal/pycore_context.h (revision 7db96d56)
  • Home
  • History
  • Annotate
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
  • only in /third_party/python/Include/internal/
1#ifndef Py_INTERNAL_CONTEXT_H
2#define Py_INTERNAL_CONTEXT_H
3
4#ifndef Py_BUILD_CORE
5#  error "this header requires Py_BUILD_CORE define"
6#endif
7
8#include "pycore_hamt.h"   /* PyHamtObject */
9
10
11extern PyTypeObject _PyContextTokenMissing_Type;
12
13/* runtime lifecycle */
14
15PyStatus _PyContext_Init(PyInterpreterState *);
16void _PyContext_Fini(PyInterpreterState *);
17
18
19/* other API */
20
21#ifndef WITH_FREELISTS
22// without freelists
23#  define PyContext_MAXFREELIST 0
24#endif
25
26#ifndef PyContext_MAXFREELIST
27#  define PyContext_MAXFREELIST 255
28#endif
29
30struct _Py_context_state {
31#if PyContext_MAXFREELIST > 0
32    // List of free PyContext objects
33    PyContext *freelist;
34    int numfree;
35#endif
36};
37
38struct _pycontextobject {
39    PyObject_HEAD
40    PyContext *ctx_prev;
41    PyHamtObject *ctx_vars;
42    PyObject *ctx_weakreflist;
43    int ctx_entered;
44};
45
46
47struct _pycontextvarobject {
48    PyObject_HEAD
49    PyObject *var_name;
50    PyObject *var_default;
51    PyObject *var_cached;
52    uint64_t var_cached_tsid;
53    uint64_t var_cached_tsver;
54    Py_hash_t var_hash;
55};
56
57
58struct _pycontexttokenobject {
59    PyObject_HEAD
60    PyContext *tok_ctx;
61    PyContextVar *tok_var;
62    PyObject *tok_oldval;
63    int tok_used;
64};
65
66
67#endif /* !Py_INTERNAL_CONTEXT_H */
68

Indexes created Thu Nov 07 10:32:03 CST 2024