Skip to content

Commit e1f1df4

Browse files
gh-141004: Document stack effect C APIs (GH-141843)
Co-authored-by: Victor Stinner <vstinner@python.org>
1 parent 5f35702 commit e1f1df4

File tree

1 file changed

+40
-0
lines changed

1 file changed

+40
-0
lines changed

Doc/c-api/veryhigh.rst

Lines changed: 40 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -396,3 +396,43 @@ Available start symbols
396396
* :pep:`484`
397397
398398
.. versionadded:: 3.8
399+
400+
401+
Stack Effects
402+
^^^^^^^^^^^^^
403+
404+
.. seealso::
405+
:py:func:`dis.stack_effect`
406+
407+
408+
.. c:macro:: PY_INVALID_STACK_EFFECT
409+
410+
Sentinel value representing an invalid stack effect.
411+
412+
This is currently equivalent to ``INT_MAX``.
413+
414+
.. versionadded:: 3.8
415+
416+
417+
.. c:function:: int PyCompile_OpcodeStackEffect(int opcode, int oparg)
418+
419+
Compute the stack effect of *opcode* with argument *oparg*.
420+
421+
On success, this function returns the stack effect; on failure, this
422+
returns :c:macro:`PY_INVALID_STACK_EFFECT`.
423+
424+
.. versionadded:: 3.4
425+
426+
427+
.. c:function:: int PyCompile_OpcodeStackEffectWithJump(int opcode, int oparg, int jump)
428+
429+
Similar to :c:func:`PyCompile_OpcodeStackEffect`, but don't include the
430+
stack effect of jumping if *jump* is zero.
431+
432+
If *jump* is ``0``, this will not include the stack effect of jumping, but
433+
if *jump* is ``1`` or ``-1``, this will include it.
434+
435+
On success, this function returns the stack effect; on failure, this
436+
returns :c:macro:`PY_INVALID_STACK_EFFECT`.
437+
438+
.. versionadded:: 3.8

0 commit comments

Comments
 (0)