File tree Expand file tree Collapse file tree 1 file changed +16
-0
lines changed
Expand file tree Collapse file tree 1 file changed +16
-0
lines changed Original file line number Diff line number Diff line change @@ -331,6 +331,22 @@ complete listing.
331331
332332 .. versionadded :: 3.11
333333
334+ .. c :macro :: Py_SAFE_DOWNCAST(value, larger, smaller)
335+
336+ Cast *value * to type *smaller * from type *larger *, validating that no
337+ information was lost.
338+
339+ On release builds of Python, this is roughly equivalent to
340+ :c:expr: `(smaller) value ` (in C++, ``static_cast<smaller>(value) `` will be
341+ used instead).
342+
343+ On debug builds (implying that :c:macro: `Py_DEBUG ` is defined), this asserts
344+ that no information was lost with the cast from *larger * to *smaller *.
345+
346+ *value *, *larger *, and *smaller * may all be evaluated more than once in the
347+ expression; as a consequence, do not pass an expensive operation directly to
348+ this macro.
349+
334350.. c :macro :: Py_STRINGIFY(x)
335351
336352 Convert ``x `` to a C string. E.g. ``Py_STRINGIFY(123) `` returns
You can’t perform that action at this time.
0 commit comments