...functions makes Python
1.04x slower when the compiler does not inline static inline
python-dev mailing list threads:
Version 2 of PEP 670 - Convert macros to functions in the Python C API
Steering Council reply to PEP 670 -- Convert macros to
functions in the Python C API
PEP 670: Convert macros to functions in the Python C API
[C API] PEP 670: Convert macros to functions in the Python C API
...Python version and must be recompiled at each Python
STATUS: Completed (in Python 3.8)
The reorganization of header files started in Python 3.7 and was
completed in Python 3.8:
bpo-35134: Add a new
Include/cpython/ subdirectory for the "CPython API" with
bpo-35081: Move internal
headers to Include/internal/
Move private functions to the internal C API
Private functions which expose implementation details must be moved to
the internal C API.
If a C extension r...
...Python bug 30071, Duck-typing inspect.isfunction() (https://bugs.python.org/issue30071)
Python bug 33261, inspect.isgeneratorfunction fails on hand-created methods
(https://bugs.python.org/issue33261 and https://github.com/python/cpython/pull/6448)
Python bug 33265, contextlib.ExitStack abuses __self__
(https://bugs.python.org/issue33265 and https://github.com/python/cpython/pull/6456)
PyMethodDef documentation (https://docs.python.org/3.7/c-api/structures.html#c.PyMethod...
from 4:30pm UTC
to 6pm UTC,
An introduction to Web Scraping with Python and Azure Functions
...python3 module definition file":
"PEP 384 branch":
"ABI type conversion script":
This document has been placed in the public domain.
Modify PyErr_*() functions to chain exceptions
Modify functions to not chain exceptions
Modify functions to chain exceptions
New helpers to chain exceptions
Python C API
Chain exceptions at C level, as already done at Python level.
Float type limited to 104 days
Previous rejected PEP
Issues caused by precision loss
Example 1: measure time delta in long-running process
Example 2: compare times with different resolution
CPython enhancements of the last 5 years
Existing Python APIs using nanoseconds as int
Alternatives and discussion
Title:Qualified name for classes and functions
Author:Antoine Pitrou <solipsis at pitrou.net>
Example with nested classes
Example with nested functions
Excluding the module name
Reviving unbound methods
This document has been placed in the public domain.
...Python for wrapped C++
Generic C++ to Python Object Interface
It is often necessary for C++ functions to manipulate
objects passed to them directly from Python, without
converting them to some other representation. Currently
Boost.Python has undocumented support for that usage when
the expected Python type is known.
Goal: Addition of a C++ type which wraps any Python
object and provides a similar interface to Python's, with
the validity of any operat...
...python.org>, Barry Warsaw <barry at python.org>
This document gives coding conventions for the C code comprising the C
implementation of Python. Please see the companion informational PEP
describing style guidelines for Python code.
Note, rules are there to be broken. Two good reasons to break a
be set to NULL, but it is strongly recommended to implement the
releaselockedbufferproc function (even if it does nothing) if any
of the acquireread/writelockedbufferproc functions are
implemented, to discourage extension writers from checking for a
NULL value and not calling it.
These functions aren't supposed to be called directly, they are
called through convenience functions declared in
int PyObject_AcquireLockedReadBuffer(PyObject *obj,
(1, 2) http://docs.python.org/3/library/functions.html#func-range
Guido van Rossum, posting to python-ideas, March 2012:
...functions in the implementation of
Rationale and Goals
The primary implementation of Python, "CPython", is written in a
mixture of Python and C. One implementation detail of CPython
is what are called "built-in" functions -- functions available to
Python programs but written in C. When a Python program calls a
built-in function and passes in arguments, those arguments must be
translated from Python values into C values. This process is called
As of CPython 3.3,...
...Python functions and be efficient as Python or built-in functions.
Changes to existing C structs
The function, method_descriptor and method classes will have their corresponding structs changed to
start with the PyExtendedCallable struct.
Third-party built-in classes using the new extended call interface
To enable call performance on a par with Python functions and built-in functions, third-party callables should set the Py_TPFLAGS_EXTENDED_CALL bit of tp_flags and ensure that the correspon...
...Python memory allocators
Title:Add new APIs to customize Python memory allocators
Author:Victor Stinner <vstinner at python.org>
BDFL-Delegate:Antoine Pitrou <solipsis at pitrou.net>
New Functions and Structures
Redesign Debug Checks on Memory Block Allocators as Hooks
cfunction object (the self in __call__ or tp_call).
This would for example allow implementing the
C call protocol for Python functions (types.FunctionType):
the C function which implements calling Python functions
needs access to the __code__ attribute of the function.
This is also needed for PEP 573
where all cfunctions require access to their "parent"
(the module for functions of a module or the defining class
Solution: add a new PyMethodDef flag to specify
that the C func...
...Python function or class. A function object contains a
reference to the function's 'globals' object, which is the __dict__ of
the module that defines it. Since the __dict__ normally has a
reference to the function there's a cycle that needs to be broken, or
else the __dict__ would never be garbage collected.
Note that a reference-count based solution doesn't work within one
module, since references between functions are by name, not by value
-- two mutually recursive functions can st...
Extensions to the API
Changes to existing APIs
Behavior of f_locals for optimized functions
Comparison with PEP 558
In early versions of Python all namespaces, whether in functions,
classes or modules, were all implemented the same way: as a dictionary.
For performance reasons, the implementation of function namespaces was