GV

GeezerVison

The World Wide Web, restored to 800 pixels of glory.

Home|About|Gaming cabinet|Archives|How it works|Starter sites

On this site

  • Sign in
  • ActionsCI/CD and automation
  • CodespacesCloud development environments
  • All Features
  • Documentation
  • Training
  • Certifications
  • Build with Copilot
  • Customize Copilot
  • Integrations
  • Trending repos
  • GitHub Sponsors
  • Developer articles
  • Enterprises

This view

  • Original page
  • New address

GeezerVison is showing github.com — gh-143535: Document dispatch behavior of singledispatchmethod by priyanshu2282-cyber · Pull Request #143592 · python/cpython

Conversation

@priyanshu2282-cyber

@priyanshu2282-cyber priyanshu2282-cyber commented Jan 9, 2026 •
edited by github-actions Bot
Loading

Uh oh!

There was an error while loading. Please reload this page.

Copy link
Copy Markdown
Contributor

The PR clarifies the behavior of singledispatchmethod in the documentation. It always dispatches the first argument during call, regardless of whether the method is bound or unbound, as a result xf(a)!=c.f(x,a). The behavior is intentional and required to support correct dispatch for staticmethod and classmethod.

  • Issue: singledispatchmethod dispatches on first argument to instance-bindable method called from class level #143535

📚 Documentation preview 📚: https://cpython-previews--143592.org.readthedocs.build/

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

All reactions
@priyanshu2282-cyber
pythongh-143535: Document dispatch behavior of singledispatchmethod
666a2a8
@priyanshu2282-cyber
priyanshu2282-cyber requested a review from rhettinger as a code owner January 9, 2026 09:50
@python-cla-bot

python-cla-bot Bot commented Jan 9, 2026 •
edited
Loading

Uh oh!

There was an error while loading. Please reload this page.

Copy link
Copy Markdown

All commit authors signed the Contributor License Agreement.

CLA signed

All reactions

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

@bedevere-app bedevere-app Bot added docs Documentation in the Doc dir skip news labels Jan 9, 2026
@github-project-automation github-project-automation Bot added this to Docs PRs Jan 9, 2026
@bedevere-app bedevere-app Bot mentioned this pull request Jan 9, 2026
singledispatchmethod dispatches on first argument to instance-bindable method called from class level #143535
Closed
@github-project-automation github-project-automation Bot moved this to Todo in Docs PRs Jan 9, 2026
@bedevere-app bedevere-app Bot added the awaiting review label Jan 9, 2026
priyanshu2282-cyber added 2 commits January 9, 2026 15:42
@priyanshu2282-cyber
pythongh-143535: Move singledispatchmethod note outside example block
ea2fda1
@priyanshu2282-cyber
Merge branch 'main' into doc-singledispatchmethod-dispatch
119a4b1
picnixz
picnixz requested changes Jan 9, 2026
View reviewed changes
Comment thread Doc/library/functools.rst Resolved

Uh oh!

There was an error while loading. Please reload this page.

@bedevere-app bedevere-app Bot removed the awaiting review label Jan 9, 2026
@bedevere-app

bedevere-app Bot commented Jan 9, 2026

Copy link
Copy Markdown

A Python core developer has requested some changes be made to your pull request before we can consider merging it. If you could please address their requests along with any other requests in other reviews from core developers that would be appreciated.

Once you have made the requested changes, please leave a comment on this pull request containing the phrase I have made the requested changes; please review again. I will then notify any core developers who have left a review that you're ready for them to take another look at this pull request.

All reactions

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

@bedevere-app bedevere-app Bot added the awaiting changes label Jan 9, 2026
@priyanshu2282-cyber
pythongh-143535: Clarify dispatch semantics of singledispatchmethod
2834c45
@priyanshu2282-cyber

priyanshu2282-cyber commented Jan 9, 2026

Copy link
Copy Markdown
Contributor Author

I have made the requested changes; please review again.

All reactions

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

@bedevere-app bedevere-app Bot added awaiting change review and removed awaiting changes labels Jan 9, 2026
@bedevere-app

bedevere-app Bot commented Jan 9, 2026

Copy link
Copy Markdown

Thanks for making the requested changes!

@picnixz: please review the changes made to this pull request.

All reactions

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

@bedevere-app
bedevere-app Bot requested a review from picnixz January 9, 2026 11:12
johnslavik
johnslavik reviewed Jan 12, 2026
View reviewed changes
Comment thread Doc/library/functools.rst Resolved

Uh oh!

There was an error while loading. Please reload this page.

priyanshu2282-cyber and others added 2 commits January 12, 2026 20:41
@priyanshu2282-cyber @johnslavik
Update Doc/library/functools.rst
57e6d20
Co-authored-by: Bartosz Sławecki <[email protected]>
@priyanshu2282-cyber
Indentation fixes
44f3295
@priyanshu2282-cyber
priyanshu2282-cyber requested a review from johnslavik January 13, 2026 14:29
picnixz
picnixz requested changes Jan 13, 2026
View reviewed changes
Comment thread Doc/library/functools.rst Outdated
Comment on lines +721 to +724
For every ``singledispatchmethod`` method defined in a class, the value
dispatched on by that method is *always* the first argument passed for the call.
Therefore, dispatching to regular methods can only be sensibly performed by
calling such a method from instances of the class, and not from the class object.

@picnixz picnixz Jan 13, 2026

Copy link
Copy Markdown
Member

There was a problem hiding this comment.

Choose a reason for hiding this comment

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

Align your paragraph with the other paragraphs, that is, use the correct indentation. You're 1 space off.

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

All reactions

@priyanshu2282-cyber priyanshu2282-cyber Jan 13, 2026

Copy link
Copy Markdown
Contributor Author

There was a problem hiding this comment.

Choose a reason for hiding this comment

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

Got it, Aligned!

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

All reactions
@bedevere-app bedevere-app Bot added awaiting changes and removed awaiting change review labels Jan 13, 2026
@bedevere-app

bedevere-app Bot commented Jan 13, 2026

Copy link
Copy Markdown

A Python core developer has requested some changes be made to your pull request before we can consider merging it. If you could please address their requests along with any other requests in other reviews from core developers that would be appreciated.

Once you have made the requested changes, please leave a comment on this pull request containing the phrase I have made the requested changes; please review again. I will then notify any core developers who have left a review that you're ready for them to take another look at this pull request.

All reactions

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

picnixz
picnixz reviewed Jan 13, 2026
View reviewed changes
Comment thread Doc/library/functools.rst Outdated
The same pattern can be used for other similar decorators:
:deco:`staticmethod`, :deco:`~abc.abstractmethod`, and others.

For every ``singledispatchmethod`` method defined in a class, the value

@picnixz picnixz Jan 13, 2026

Copy link
Copy Markdown
Member

There was a problem hiding this comment.

Choose a reason for hiding this comment

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

You don't define a singledispatchmethod, you decorate one with this decorator. See the other paragraphs.

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

johnslavik reacted with thumbs up emoji
All reactions
  • 👍 1 reaction

@johnslavik johnslavik Jan 13, 2026 •
edited
Loading

Uh oh!

There was an error while loading. Please reload this page.

Copy link
Copy Markdown
Member

There was a problem hiding this comment.

Choose a reason for hiding this comment

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

You don't define a singledispatchmethod

It doesn't say singledispatchmethod defined in a class, but singledispatchmethod method defined in a class.

However, I agree that the current wording can be better. If it was good, you wouldn't have raised the thread.

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

All reactions

@priyanshu2282-cyber priyanshu2282-cyber Jan 13, 2026

Copy link
Copy Markdown
Contributor Author

There was a problem hiding this comment.

Choose a reason for hiding this comment

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

Thanks for your clarification, I have used the decorators as suggested, and updated the PR.

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

All reactions
@priyanshu2282-cyber
pythongh-143535: Fix indentation in singledispatchmethod docs
e033b66
@priyanshu2282-cyber

priyanshu2282-cyber commented Jan 13, 2026

Copy link
Copy Markdown
Contributor Author

I have made the requested changes; please review again

All reactions

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

@bedevere-app bedevere-app Bot added awaiting change review and removed awaiting changes labels Jan 13, 2026
@bedevere-app

bedevere-app Bot commented Jan 13, 2026

Copy link
Copy Markdown

Thanks for making the requested changes!

@picnixz: please review the changes made to this pull request.

All reactions

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

@bedevere-app
bedevere-app Bot requested a review from picnixz January 13, 2026 18:13
@picnixz

picnixz commented Jan 13, 2026

Copy link
Copy Markdown
Member

You did not address all my comments. I am going offline but I really need you to address everything before requesting a review as this makes me lose my time.

All reactions

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

@priyanshu2282-cyber
Used decorators
48d6546
@priyanshu2282-cyber

priyanshu2282-cyber commented Jan 14, 2026 •
edited
Loading

Uh oh!

There was an error while loading. Please reload this page.

Copy link
Copy Markdown
Contributor Author

Sorry for the back-and-forth. I’ve addressed all the review comments and also I have made the requested changes; please review again @picnixz

All reactions

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

@priyanshu2282-cyber

priyanshu2282-cyber commented Jan 20, 2026

Copy link
Copy Markdown
Contributor Author

Hi @johnslavik, just checking in on this PR in case it slipped through. No rush at all, would appreciate your feedback when you have time. Thanks!

All reactions

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

@jaraco

jaraco commented Feb 15, 2026

Copy link
Copy Markdown
Member

#144615 demonstrates that this behavior can be fairly easily accounted for. I'd prefer to elevate the capability rather than document the deficiency.

All reactions

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

@picnixz

picnixz commented Feb 16, 2026

Copy link
Copy Markdown
Member

Agreed. Let us close this one then.

All reactions

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

@picnixz picnixz closed this Feb 16, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Reviewers

@rhettinger rhettinger Awaiting requested review from rhettinger rhettinger is a code owner
@johnslavik johnslavik Awaiting requested review from johnslavik
@picnixz picnixz Awaiting requested review from picnixz

Uh oh!

There was an error while loading. Please reload this page.

Assignees

No one assigned

Labels

awaiting change review docs Documentation in the Doc dir skip news

Projects

Docs PRs
Status: Todo

Milestone

No milestone

Development

Successfully merging this pull request may close these issues.

Uh oh!

There was an error while loading. Please reload this page.

4 participants

@priyanshu2282-cyber @picnixz @jaraco @johnslavik
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
You are visitor 01402503 — GeezerVison does not store the pages you look up.
Best viewed with Netscape Navigator 4.7 or Internet Explorer 6 at 800×600. No cookies required.