mirror of
https://github.com/python/cpython.git
synced 2024-11-27 20:04:41 +08:00
bpo-35081: Add _PyTuple_CAST() (GH-10704)
This commit is contained in:
parent
158695817d
commit
8ac6539d85
@ -55,15 +55,18 @@ PyAPI_FUNC(void) _PyTuple_MaybeUntrack(PyObject *);
|
|||||||
|
|
||||||
/* Macro, trading safety for speed */
|
/* Macro, trading safety for speed */
|
||||||
#ifndef Py_LIMITED_API
|
#ifndef Py_LIMITED_API
|
||||||
#define PyTuple_GET_ITEM(op, i) (((PyTupleObject *)(op))->ob_item[i])
|
/* Cast argument to PyTupleObject* type. */
|
||||||
#define PyTuple_GET_SIZE(op) (assert(PyTuple_Check(op)),Py_SIZE(op))
|
#define _PyTuple_CAST(op) ((PyTupleObject *)(op))
|
||||||
|
|
||||||
|
#define PyTuple_GET_ITEM(op, i) (_PyTuple_CAST(op)->ob_item[i])
|
||||||
|
#define PyTuple_GET_SIZE(op) (assert(PyTuple_Check(op)), Py_SIZE(op))
|
||||||
|
|
||||||
#ifdef Py_BUILD_CORE
|
#ifdef Py_BUILD_CORE
|
||||||
# define _PyTuple_ITEMS(op) ((((PyTupleObject *)(op))->ob_item))
|
# define _PyTuple_ITEMS(op) (_PyTuple_CAST(op)->ob_item)
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
/* Macro, *only* to be used to fill in brand new tuples */
|
/* Macro, *only* to be used to fill in brand new tuples */
|
||||||
#define PyTuple_SET_ITEM(op, i, v) (((PyTupleObject *)(op))->ob_item[i] = v)
|
#define PyTuple_SET_ITEM(op, i, v) (_PyTuple_CAST(op)->ob_item[i] = v)
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
PyAPI_FUNC(int) PyTuple_ClearFreeList(void);
|
PyAPI_FUNC(int) PyTuple_ClearFreeList(void);
|
||||||
|
Loading…
Reference in New Issue
Block a user