Skip to content

Conversation

@rroblf01
Copy link

@rroblf01 rroblf01 commented Nov 16, 2025

This pull request introduces a new PEP draft (pep-8108.rst) proposing the addition of a coroutinedispatch class to the functools module. The main goal is to enable method overloading based on argument types, supporting both synchronous and asynchronous methods, thus improving code readability and maintainability in Python.

New PEP proposal for method overloading in functools:

  • Added PEP 8108 draft, detailing the motivation, rationale, specification, and example usage for a new coroutinedispatch class in the Python standard library.
  • Provided a reference implementation of coroutinedispatch, including registration of method overloads, type matching logic, support for async/sync methods, and error handling for unmatched types.
  • Included example usage demonstrating how to define and invoke overloaded methods for both synchronous and asynchronous contexts.
  • Clarified backwards compatibility, security implications, and documentation/teaching strategy for the proposed feature.… functools

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

@rroblf01 rroblf01 requested a review from a team as a code owner November 16, 2025 16:31
@python-cla-bot
Copy link

python-cla-bot bot commented Nov 16, 2025

All commit authors signed the Contributor License Agreement.

CLA signed

@hugovk
Copy link
Member

hugovk commented Nov 16, 2025

Thanks for the suggestion but please see the process in PEP 1.

Notably, start with a discussion in the Ideas forum and then find a sponsor.

Thank you!

@hugovk hugovk closed this Nov 16, 2025
@hugovk hugovk changed the title PEP 8108: Introduce coroutinedispatch class for method overloading in… PEP 999: Introduce coroutinedispatch class for method overloading in… Nov 16, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants