Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
35 changes: 29 additions & 6 deletions peps/pep-0818.rst
Original file line number Diff line number Diff line change
Expand Up @@ -2,11 +2,14 @@ PEP: 818
Title: Adding the Core of the Pyodide Foreign Function Interface to Python
Author: Hood Chatham <roberthoodchatham at gmail.com>
Sponsor: Łukasz Langa <lukasz at python.org>
Discussions-To: https://discuss.python.org/t/pep-818-upstreaming-the-pyodide-ffi/105530
Discussions-To: https://discuss.python.org/t/pep-818-adding-the-core-of-the-pyodide-foreign-function-interface-to-python-2/109311
Status: Draft
Type: Standards Track
Created: 10-Dec-2025
Python-Version: 3.16
Post-History: `05-Jan-2026 <https://discuss.python.org/t/pep-818-upstreaming-the-pyodide-ffi/105530>`__,
`01-Oct-2026 <https://discuss.python.org/t/pep-818-adding-the-core-of-the-pyodide-foreign-function-interface-to-python-2/109311>`__


Comment thread
hoodmane marked this conversation as resolved.
Abstract
========
Expand Down Expand Up @@ -62,10 +65,8 @@ supporting ``urllib3``, ``aiohttp``, and ``httpx`` requires the foreign function
interface.

In order to keep the length of this PEP reasonable, we focus on the "core" of
the foreign function interface. The following areas are left to future PEPs:

1. asyncio
2. a JavaScript interface for managing the Python runtime
the foreign function interface. The JavaScript interface for managing the Python
runtime is left to a future PEP.


Rationale
Expand Down Expand Up @@ -1545,6 +1546,28 @@ run on.
How to Teach This
=================

Pyodide has maintained a user guide for this foreign function interface for
several years, and the existing `Pyodide type translation documentation
<https://pyodide.org/en/stable/usage/type-conversions.html>`__ can be adapted to
form the basis of the CPython documentation.

We have substantial experience in teaching users how to use Pyodide and for the
most part they find it very intuitive. The main area that trips up users is
memory management of ``PyProxy`` objects. For this reason, we have taken special
care to design the memory management error messages to be actionable.


Change History
==============

- 30-Sept-2026

- Reduced the amount of detail in the specification section.
- Added support for proxying and conversion of buffers.
- Added asyncio support, including an event loop, conversion between Python
and JavaScript awaitables, and deferred destruction for arguments to an
asynchronous JavaScript function called from Python.


Reference Implementation
========================
Expand All @@ -1555,7 +1578,7 @@ Pyodide, https://github.com/hoodmane/cpython/tree/js-ffi
Acknowledgments
===============

Mike Droettboom, Roman Yurchak, Gyeongjae Choi, Andrea Giammarchi
Mike Droettboom, Roman Yurchak, Gyeongjae Choi, Andrea Giammarchi, and Thorsten Beier.

Copyright
=========
Expand Down
Loading