cpython/Include
Hood Chatham 6b179adb8c
gh-106213: Make Emscripten trampolines work with JSPI (GH-106219)
There is a WIP proposal to enable webassembly stack switching which have been
implemented in v8:

https://github.com/WebAssembly/js-promise-integration

It is not possible to switch stacks that contain JS frames so the Emscripten JS
trampolines that allow calling functions with the wrong number of arguments
don't work in this case. However, the js-promise-integration proposal requires
the [type reflection for Wasm/JS API](https://github.com/WebAssembly/js-types)
proposal, which allows us to actually count the number of arguments a function
expects.

For better compatibility with stack switching, this PR checks if type reflection
is available, and if so we use a switch block to decide the appropriate
signature. If type reflection is unavailable, we should use the current EMJS
trampoline.

We cache the function argument counts since when I didn't cache them performance
was negatively affected.

Co-authored-by: T. Wouters <thomas@python.org>
Co-authored-by: Brett Cannon <brett@python.org>
2023-09-15 15:04:21 -07:00
..
cpython GH-104584: Don't call executors from JUMP_BACKWARD (GH-109347) 2023-09-13 10:26:50 -07:00
internal gh-106213: Make Emscripten trampolines work with JSPI (GH-106219) 2023-09-15 15:04:21 -07:00
abstract.h gh-106307: C API: Add PyMapping_GetOptionalItem() function (GH-106308) 2023-07-11 23:04:12 +03:00
bltinmodule.h
boolobject.h gh-84436: Implement Immortal Objects (gh-19474) 2023-04-22 13:39:37 -06:00
bytearrayobject.h gh-87347: Add parenthesis around PyXXX_Check() arguments (#92815) 2022-06-16 13:49:43 +02:00
bytesobject.h gh-108765: Move standard includes to Python.h (#108769) 2023-09-01 21:03:20 +02:00
ceval.h gh-105182: Remove PyEval_AcquireLock() and PyEval_InitThreads() (#105183) 2023-06-01 13:41:56 +02:00
codecs.h Remove private _PyCodec_Lookup() function (#106269) 2023-06-30 09:34:01 +00:00
compile.h bpo-35134: Add include/cpython/compile.h (GH-24922) 2021-03-22 09:32:11 +01:00
complexobject.h gh-87347: Add parenthesis around PyXXX_Check() arguments (#92815) 2022-06-16 13:49:43 +02:00
datetime.h gh-87347: Add parenthesis around macro arguments (#93915) 2022-06-20 16:04:52 +02:00
descrobject.h gh-103509: PEP 697 -- Limited C API for Extending Opaque Types (GH-103511) 2023-05-04 09:56:53 +02:00
dictobject.h gh-106004: PyDict_GetItemRef() should only be in the limited API 3.13 (GH-107229) 2023-07-25 21:48:07 +03:00
dynamic_annotations.h gh-96959: Update HTTP links which are redirected to HTTPS (GH-96961) 2022-09-24 14:38:53 +03:00
enumobject.h
errcode.h gh-107162: Document errcode.h usage in its comment (#107177) 2023-07-24 14:14:58 +00:00
exports.h gh-108765: Move export code from pyport.h to exports.h (#108855) 2023-09-04 01:04:05 +02:00
fileobject.h gh-106320: Remove _PyIsSelectable_fd() C API (#107142) 2023-07-23 19:07:12 +00:00
fileutils.h gh-108765: Move stat() fiddling from pyport.h to fileutils.h (#108854) 2023-09-03 21:32:13 +00:00
floatobject.h gh-87347: Add parenthesis around PyXXX_Check() arguments (#92815) 2022-06-16 13:49:43 +02:00
frameobject.h bpo-45434: Remove useless space in includes (GH-28963) 2021-10-15 01:50:04 +02:00
genericaliasobject.h bpo-44654: Refactor and clean up the union type implementation (GH-27196) 2021-07-17 22:44:10 +03:00
import.h gh-105922: Add PyImport_AddModuleRef() function (#105923) 2023-06-20 08:48:14 +02:00
interpreteridobject.h gh-101524: Only Use Public C-API in the _xxsubinterpreters Module (gh-107359) 2023-07-27 15:30:16 -06:00
intrcheck.h gh-106320: Remove private _PyOS_IsMainThread() function (#108605) 2023-08-29 03:20:31 +00:00
iterobject.h gh-106320: Remove _PyAnextAwaitable_Type from the public C API (#108597) 2023-08-29 02:05:11 +00:00
listobject.h gh-87347: Add parenthesis around PyXXX_Check() arguments (#92815) 2022-06-16 13:49:43 +02:00
longobject.h gh-108444: Add PyLong_AsInt() public function (#108445) 2023-08-24 23:55:30 +02:00
marshal.h bpo-45474: Exclude all of marshal.h if Py_LIMITED_API is defined (GH-29061) 2021-10-20 02:32:14 -07:00
memoryobject.h gh-79315: Add Include/cpython/memoryobject.h header (#99723) 2022-11-23 15:44:42 +01:00
methodobject.h gh-105107: Remove PyCFunction_Call() function (#105181) 2023-06-01 11:25:55 +02:00
modsupport.h gh-108765: Move standard includes to Python.h (#108769) 2023-09-01 21:03:20 +02:00
moduleobject.h gh-106320: Remove private _PyModule API (#107070) 2023-07-22 21:41:11 +00:00
object.h gh-108765: Move standard includes to Python.h (#108769) 2023-09-01 21:03:20 +02:00
objimpl.h gh-108765: Move standard includes to Python.h (#108769) 2023-09-01 21:03:20 +02:00
opcode.h gh-105481: opcode.h is no longer generated during the build (#108080) 2023-08-17 17:07:58 +01:00
opcode_ids.h GH-105848: Replace KW_NAMES + CALL with LOAD_CONST + CALL_KW (GH-109300) 2023-09-13 10:25:45 -07:00
osdefs.h gh-108765: Reformat Include/osdefs.h (#108766) 2023-09-01 14:35:39 +00:00
osmodule.h Issue #29058: All stable API extensions added after Python 3.2 are now 2016-12-27 14:57:39 +02:00
patchlevel.h Python 3.13.0a0 2023-05-22 21:15:32 +02:00
py_curses.h gh-87347: Add parenthesis around PyXXX_Check() arguments (#92815) 2022-06-16 13:49:43 +02:00
pybuffer.h gh-102500: Implement PEP 688 (#102521) 2023-05-04 07:59:46 -07:00
pycapsule.h gh-108240: Add pycore_capsule.h internal header file (#108596) 2023-08-29 01:20:02 +00:00
pydtrace.d bpo-36842: Implement PEP 578 (GH-12613) 2019-05-23 08:45:22 -07:00
pydtrace.h Fix pydtrace.d path comment in Include/pydtrace.h (#28539) 2022-12-31 22:40:25 +05:30
pyerrors.h gh-108765: Move standard includes to Python.h (#108769) 2023-09-01 21:03:20 +02:00
pyexpat.h bpo-34623: Use XML_SetHashSalt in _elementtree (GH-9146) 2018-09-18 05:38:58 -07:00
pyframe.h gh-93937, C API: Move PyFrame_GetBack() to Python.h (#93938) 2022-06-19 12:02:33 +02:00
pyhash.h gh-106320: Move private _PyHash API to the internal C API (#107026) 2023-07-22 13:49:37 +00:00
pylifecycle.h gh-105145: Deprecate Py_GetPath() function (#105179) 2023-06-01 12:06:32 +00:00
pymacconfig.h gh-108765: Reformat Include/pymacconfig.h (#108764) 2023-09-01 14:57:28 +00:00
pymacro.h gh-107249: Implement Py_UNUSED() for MSVC (#107250) 2023-07-25 19:28:16 +02:00
pymath.h gh-104263: Rely on Py_NAN and introduce Py_INFINITY (GH-104202) 2023-05-10 17:44:52 +01:00
pymem.h gh-108765: Move standard includes to Python.h (#108769) 2023-09-01 21:03:20 +02:00
pyport.h gh-108765: Move export code from pyport.h to exports.h (#108855) 2023-09-04 01:04:05 +02:00
pystate.h bpo-45459: C API uses type names rather than structure names (GH-31528) 2022-02-24 17:51:59 +01:00
pystats.h gh-108753: Enhance pystats (#108754) 2023-09-06 15:54:59 +00:00
pystrcmp.h
pystrtod.h gh-106320: Remove private float C API functions (#108430) 2023-08-24 19:09:49 +02:00
Python.h gh-108765: Python.h no longer includes <ctype.h> (#108831) 2023-09-03 18:54:27 +02:00
pythonrun.h gh-102755: PyErr_DisplayException only in ABI >= 3.12. Tests cover PyErr_Display as well (GH-102849) 2023-03-21 10:36:18 +01:00
pythread.h bpo-42047: Add native thread ID for DragonFlyBSD (#22714) 2022-05-18 15:10:10 +02:00
pytypedefs.h bpo-45459: Fix PyModuleDef_Slot type in the limited C API (GH-31668) 2022-03-03 23:06:55 +01:00
rangeobject.h gh-87347: Add parenthesis around PyXXX_Check() arguments (#92815) 2022-06-16 13:49:43 +02:00
README.rst gh-101101: Unstable C API tier (PEP 689) (GH-101102) 2023-02-28 09:31:01 +01:00
setobject.h gh-87347: Add parenthesis around PyXXX_Check() arguments (#92815) 2022-06-16 13:49:43 +02:00
sliceobject.h gh-87347: Add parenthesis around PyXXX_Check() arguments (#92815) 2022-06-16 13:49:43 +02:00
structmember.h gh-47146: Soft-deprecate structmember.h, expose its contents via Python.h (GH-99014) 2022-11-22 08:25:43 +01:00
structseq.h gh-106168: PyTuple_SET_ITEM() now checks the index (#106164) 2023-06-28 03:45:57 +02:00
sysmodule.h gh-105145: Deprecate Py_GetPath() function (#105179) 2023-06-01 12:06:32 +00:00
traceback.h gh-87347: Add parenthesis around PyXXX_Check() arguments (#92815) 2022-06-16 13:49:43 +02:00
tupleobject.h gh-87347: Add parenthesis around PyXXX_Check() arguments (#92815) 2022-06-16 13:49:43 +02:00
typeslots.h bpo-45459: Add Py_buffer to limited API (GH-29991) 2022-02-02 07:03:10 -08:00
unicodeobject.h gh-108765: Move standard includes to Python.h (#108769) 2023-09-01 21:03:20 +02:00
warnings.h bpo-35134: Split warnings.h and weakrefobject.h (GH-29042) 2021-10-19 01:31:57 +02:00
weakrefobject.h gh-105927: Deprecate PyWeakref_GetObject() function (#106006) 2023-06-26 12:10:53 +02:00

The Python C API
================

The C API is divided into these sections:

1. ``Include/``: Limited API
2. ``Include/cpython/``: CPython implementation details
3. ``Include/cpython/``, names with the ``PyUnstable_`` prefix: API that can
   change between minor releases
4. ``Include/internal/``, and any name with ``_`` prefix: The internal API

Information on changing the C API is available `in the developer guide`_

.. _in the developer guide: https://devguide.python.org/c-api/