Skip to content

Commit d95aef5

Browse files
Add _PyCode_GetVarCounts().
1 parent 219d8d2 commit d95aef5

File tree

4 files changed

+696
-0
lines changed

4 files changed

+696
-0
lines changed

Include/internal/pycore_code.h

Lines changed: 43 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -564,6 +564,49 @@ extern int _Py_ClearUnusedTLBC(PyInterpreterState *interp);
564564
#endif
565565

566566

567+
typedef struct {
568+
int total;
569+
struct co_locals_counts {
570+
int total;
571+
struct {
572+
int total;
573+
int numposonly;
574+
int numposorkw;
575+
int numkwonly;
576+
int varargs;
577+
int varkwargs;
578+
} args;
579+
int numpure;
580+
struct {
581+
int total;
582+
// numargs does not contribute to locals.total.
583+
int numargs;
584+
int numothers;
585+
} cells;
586+
struct {
587+
int total;
588+
int numpure;
589+
int numcells;
590+
} hidden;
591+
} locals;
592+
int numfree; // nonlocal
593+
struct co_unbound_counts {
594+
int total;
595+
int numglobal;
596+
int numattrs;
597+
int numunknown;
598+
} unbound;
599+
} _PyCode_var_counts_t;
600+
601+
PyAPI_FUNC(void) _PyCode_GetVarCounts(
602+
PyCodeObject *,
603+
_PyCode_var_counts_t *);
604+
PyAPI_FUNC(int) _PyCode_SetUnboundVarCounts(
605+
PyCodeObject *,
606+
_PyCode_var_counts_t *,
607+
PyObject *global,
608+
PyObject *attrs);
609+
567610
PyAPI_FUNC(int) _PyCode_ReturnsOnlyNone(PyCodeObject *);
568611

569612

0 commit comments

Comments
 (0)