Search results
3 days ago · This manual documents the API used by C and C++ programmers who want to write extension modules or embed Python. It is a companion to Extending and Embedding the Python Interpreter, which describes the general principles of extension writing but does not document the API functions in detail.
- Importing Modules
PyObject * PyImport_Import (PyObject * name) ¶ Return value:...
- Introduction
Most Python/C API functions have one or more arguments as...
- Reflection
Return value: Borrowed reference. Part of the Stable ABI ....
- Mapping Protocol
PyObject * PyMapping_Items (PyObject * o) ¶ Return value:...
- Buffer Protocol
For contiguous arrays, the value points to the beginning of...
- Operating System Utilities
void PyOS_AfterFork_Parent ¶ Part of the Stable ABI on...
- Call Protocol
PyObject * PyObject_CallObject (PyObject * callable,...
- Number Protocol
PyObject * PyNumber_InPlaceFloorDivide (PyObject * o1,...
- Importing Modules
Most Python/C API functions have one or more arguments as well as a return value of type :c:expr:`PyObject*`. This type is a pointer to an opaque data type representing an arbitrary Python object.
Jul 16, 2023 · Types in CPython are defined by the _typeobject struct. This C struct is actually the base of all the types used in CPython and it has many fields that are mostly pointers to other C...
Mar 11, 2010 · A few structure types are used to describe static tables used to list the functions exported by a module or the data attributes of a new object type, and another is used to describe the value of a complex number.
Changing Python’s C API¶ The C API is divided into these tiers: The internal, private API, available with Py_BUILD_CORE defined. Ideally declared in Include/internal/. Any API named with a leading underscore is also considered private. The Unstable C API, identified by the PyUnstable_ name prefix.
.. c:function:: PyObject * PyObject_RichCompare (PyObject * o1, PyObject * o2, int opid) Compare the values of * o1 * and * o2 * using the operation specified by * opid *, which must be one of: c: macro:` Py_LT `, : c: macro:` Py_LE `, : c: macro:` Py_EQ `, : c: macro:` Py_NE `, : c: macro:` Py_GT `, or: c: macro:` Py_GE `, corresponding to ...
People also ask
What is the Python/C API?
What is a Python API manual?
Where can I find CPython's public C API?
Can I use Python API in C++?
What is CPython internal API?
Where do CPython tests live?
The API is equally usable from C++, but for brevity it is generally referred to as the Python/C API. There are two fundamentally different reasons for using the Python/C API. The first reason is to write extension modules for specific purposes; these are C modules that extend the Python interpreter.