Skip to content

Conversation

ZeroIntensity
Copy link
Member

@ZeroIntensity ZeroIntensity commented Aug 8, 2025

Basic requirements (all PEP Types)

  • Read and followed PEP 1 & PEP 12
  • File created from the latest PEP template
  • PEP has next available number, & set in filename (pep-NNNN.rst), PR title (PEP 123: <Title of PEP>) and PEP header
  • Title clearly, accurately and concisely describes the content in 79 characters or less
  • Core dev/PEP editor listed as Author or Sponsor, and formally confirmed their approval
  • Author, Status (Draft), Type and Created headers filled out correctly
  • PEP-Delegate, Topic, Requires and Replaces headers completed if appropriate
  • Required sections included
    • Abstract (first section)
    • Copyright (last section; exact wording from template required)
  • Code is well-formatted (PEP 7/PEP 8) and is in code blocks, with the right lexer names if non-Python
  • PEP builds with no warnings, pre-commit checks pass and content displays as intended in the rendered HTML
  • Authors/sponsor added to .github/CODEOWNERS for the PEP

Standards Track requirements

  • PEP topic discussed in a suitable venue with general agreement that a PEP is appropriate
  • Suggested sections included (unless not applicable)
    • Motivation
    • Rationale
    • Specification
    • Backwards Compatibility
    • Security Implications
    • How to Teach This
    • Reference Implementation
    • Rejected Ideas
    • Open Issues
  • Python-Version set to valid (pre-beta) future Python version, if relevant
  • Any project stated in the PEP as supporting/endorsing/benefiting from the PEP formally confirmed such
  • Right before or after initial merging, PEP discussion thread created and linked to in Discussions-To and Post-History

📚 Documentation preview 📚: https://pep-previews--4536.org.readthedocs.build/pep-0797/

@ZeroIntensity ZeroIntensity requested a review from a team as a code owner August 8, 2025 16:54
@brianschubert brianschubert added the new-pep A new draft PEP submitted for initial review label Aug 8, 2025
Abstract
========

This PEP introduces a new :func:`~concurrent.interpreters.share` function to
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
This PEP introduces a new :func:`~concurrent.interpreters.share` function to
This PEP introduces a new :func:`!share` function to


This PEP introduces a new :func:`~concurrent.interpreters.share` function to
the :mod:`concurrent.interpreters` module, which allows *any* arbitrary object
to be shared for a period of time.
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Shared between what? Processes, threads, interpreters, over the network, etc?


from concurrent import interpreters

with open("spanish_inquisition.txt") as unshareable:
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

always use an encoding!

Suggested change
with open("spanish_inquisition.txt") as unshareable:
with open('spanish_inquisition.txt', encoding='utf-8') as unshareable:

Comment on lines +37 to +38
create multiple interpreters in a single Python process. This works well for
stateless code (that is, code that doesn't need any state from a caller) and
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
create multiple interpreters in a single Python process. This works well for
stateless code (that is, code that doesn't need any state from a caller) and
create multiple interpreters in a single Python process. This works well for
code that doesn't need any state from a caller ('stateless code') and

create multiple interpreters in a single Python process. This works well for
stateless code (that is, code that doesn't need any state from a caller) and
objects that can be serialized, but it is fairly common for applications to
want to use highly-complex data structures (that cannot be serialized) with
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

In general I would use fewer paranthetical asides, though this is style. Here, I don't think the comment about serialisation adds much, it's clear from context we're talking about non-serialisable data (or even data that could be serialised but that is too expensive to do so)

Suggested change
want to use highly-complex data structures (that cannot be serialized) with
require highly-complex data structures with

Comment on lines +214 to +217
In order to implement the immortality mechanism used by shared object proxies,
several assumptions had to be made about the object lifecycle in the C API.
So, some best practices in the C API (such as using the object allocator for
objects) are made harder requirements by the implementation of this PEP.
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Be explicit about what those assumptions are. In general, it is hard to make assumptions about what code in the wild is or is not doing (Hyrum's Law etc)

Comment on lines +219 to +221
The author of this PEP believes it is unlikely that this will cause breakage,
as he has not ever seen code in the wild that violates the assumptions made
about the object lifecycle as required by the reference implementation.
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

There are millions of lines of proprietary code that you & I haven't seen ;-)

More generally just re-emphasising the point on explicitly enumerating the changes in semantics that you propose.

which prevents any concurrent modification to their reference count.
This can cause them to take up very large amounts of memory if mismanaged.

The :func:`~concurrent.interpreters.share` context manager does its best
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
The :func:`~concurrent.interpreters.share` context manager does its best
The :func:`!share` context manager does its best

The largest issue with shared object proxies is that in order to have
thread-safe reference counting operations, they must be :term:`immortal`,
which prevents any concurrent modification to their reference count.
This can cause them to take up very large amounts of memory if mismanaged.
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Large amounts of memory -> denial of service attack, which is the actual security concern here

Comment on lines +57 to +58
usage (due to :term:`immortality <immortal>`, which will be discussed more
later). As such, this PEP does not make other mechanisms for sharing objects
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Which part/section are you referring to here?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
new-pep A new draft PEP submitted for initial review
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants