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-102936: typing: document performance pitfalls of protocols decorated with `@runtime_checkable` by AlexWaygood · Pull Request #102937 · python/cpython

Conversation

@AlexWaygood

@AlexWaygood AlexWaygood commented Mar 22, 2023 •
edited by bedevere-bot
Loading

Uh oh!

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

Copy link
Copy Markdown
Member
  • Issue: Typing: Document performance pitfalls of protocols decorated with @runtime_checkable #102936

Sorry, something went wrong.

Uh oh!

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

All reactions
@AlexWaygood
Typing: document performance pitfalls of protocols decorated with `@r…
c70742e
…untime_checkable`
@AlexWaygood
AlexWaygood requested a review from hauntsaninja March 22, 2023 22:49
@AlexWaygood
AlexWaygood requested review from Fidget-Spinner, JelleZijlstra and gvanrossum as code owners March 22, 2023 22:49
@bedevere-bot bedevere-bot added docs Documentation in the Doc dir skip news labels Mar 22, 2023
@bedevere-bot bedevere-bot mentioned this pull request Mar 22, 2023
Typing: Document performance pitfalls of protocols decorated with @runtime_checkable #102936
Closed
@bedevere-bot bedevere-bot added the awaiting core review label Mar 22, 2023
@AlexWaygood AlexWaygood added needs backport to 3.10 topic-typing needs backport to 3.11 only security fixes labels Mar 22, 2023
gvanrossum
gvanrossum approved these changes Mar 22, 2023
View reviewed changes

@gvanrossum gvanrossum left a comment

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.

Makes sense.

Sorry, something went wrong.

Uh oh!

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

AlexWaygood reacted with heart emoji
All reactions
  • ❤️ 1 reaction
@bedevere-bot bedevere-bot added awaiting merge and removed awaiting core review labels Mar 22, 2023
hauntsaninja
hauntsaninja reviewed Mar 23, 2023
View reviewed changes

@hauntsaninja hauntsaninja left a comment

Copy link
Copy Markdown
Contributor

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 doing this! Had one suggestion for a different example of attribute

Sorry, something went wrong.

Uh oh!

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

All reactions
Comment thread Doc/library/typing.rst

assert isinstance(open('/some/file'), Closable)

@runtime_checkable

@hauntsaninja hauntsaninja Mar 23, 2023

Copy link
Copy Markdown
Contributor

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.

I think many users aren't too familiar with OSError's constructor / we can't use kwargs and it's unclear what the second argument is. Maybe we could use int and HasNumerator instead?

(I know it's not writeable, but OSError's errno also is maybe not writeable? Writing to errno doesn't affect repr)

Sorry, something went wrong.

Uh oh!

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

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

@AlexWaygood AlexWaygood Mar 23, 2023

Copy link
Copy Markdown
Member 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.

Yeah, I was really struggling to think of a good example for this! I'll ponder some more and see if I can come up with something better...

Sorry, something went wrong.

Uh oh!

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

All reactions

@hauntsaninja hauntsaninja Mar 23, 2023

Copy link
Copy Markdown
Contributor

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.

Perhaps unsurprisingly, not too many good cases of writeable attributes in stdlib. Maybe Thread.name? It's explicitly documented as something you can write to.

Sorry, something went wrong.

Uh oh!

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

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

@AlexWaygood AlexWaygood Mar 23, 2023

Copy link
Copy Markdown
Member 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.

That works! I'll make the change tomorrow (it's late here)

Sorry, something went wrong.

Uh oh!

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

All reactions
Comment thread Doc/library/typing.rst Resolved

Uh oh!

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

@AlexWaygood
A thread named Bob
7666617
@AlexWaygood
AlexWaygood requested a review from hauntsaninja March 23, 2023 13:42
furkanonder
furkanonder approved these changes Mar 23, 2023
View reviewed changes
hauntsaninja
hauntsaninja approved these changes Mar 23, 2023
View reviewed changes
@AlexWaygood
AlexWaygood merged commit 58d2b30 into python:main Mar 23, 2023
@miss-islington

miss-islington commented Mar 23, 2023

Copy link
Copy Markdown
Contributor

Thanks @AlexWaygood for the PR 🌮🎉.. I'm working now to backport this PR to: 3.10, 3.11.
🐍🍒⛏🤖

All reactions

Sorry, something went wrong.

Uh oh!

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

@bedevere-bot bedevere-bot removed the awaiting merge label Mar 23, 2023
@AlexWaygood
AlexWaygood deleted the document-runtime_checkable-quite-bad branch March 23, 2023 18:18
miss-islington pushed a commit to miss-islington/cpython that referenced this pull request Mar 23, 2023
@AlexWaygood @miss-islington
pythongh-102936: typing: document performance pitfalls of protocols d…
924e20e
…ecorated with `@runtime_checkable` (pythonGH-102937)

(cherry picked from commit 58d2b30)

Co-authored-by: Alex Waygood <[email protected]>
@bedevere-bot

bedevere-bot commented Mar 23, 2023

Copy link
Copy Markdown

GH-102963 is a backport of this pull request to the 3.11 branch.

All reactions

Sorry, something went wrong.

Uh oh!

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

miss-islington pushed a commit to miss-islington/cpython that referenced this pull request Mar 23, 2023
@AlexWaygood @miss-islington
pythongh-102936: typing: document performance pitfalls of protocols d…
8cd301d
…ecorated with `@runtime_checkable` (pythonGH-102937)

(cherry picked from commit 58d2b30)

Co-authored-by: Alex Waygood <[email protected]>
@bedevere-bot bedevere-bot removed the needs backport to 3.11 only security fixes label Mar 23, 2023
@bedevere-bot

bedevere-bot commented Mar 23, 2023

Copy link
Copy Markdown

GH-102964 is a backport of this pull request to the 3.10 branch.

All reactions

Sorry, something went wrong.

Uh oh!

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

@bedevere-bot bedevere-bot removed the needs backport to 3.10 label Mar 23, 2023
@AlexWaygood

AlexWaygood commented Mar 23, 2023

Copy link
Copy Markdown
Member Author

Thanks all for the reviews!

All reactions

Sorry, something went wrong.

Uh oh!

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

miss-islington added a commit that referenced this pull request Mar 23, 2023
@miss-islington @AlexWaygood
gh-102936: typing: document performance pitfalls of protocols decorat…
e2924c0
…ed with `@runtime_checkable` (GH-102937)

(cherry picked from commit 58d2b30)

Co-authored-by: Alex Waygood <[email protected]>
miss-islington added a commit that referenced this pull request Mar 23, 2023
@miss-islington @AlexWaygood
gh-102936: typing: document performance pitfalls of protocols decorat…
6c667d0
…ed with `@runtime_checkable` (GH-102937)

(cherry picked from commit 58d2b30)

Co-authored-by: Alex Waygood <[email protected]>
Fidget-Spinner pushed a commit to Fidget-Spinner/cpython that referenced this pull request Mar 27, 2023
@AlexWaygood @Fidget-Spinner
pythongh-102936: typing: document performance pitfalls of protocols d…
10b47a8
…ecorated with `@runtime_checkable` (python#102937)
@AlexWaygood AlexWaygood mentioned this pull request Apr 5, 2023
Performance of typing._ProtocolMeta._get_protocol_attrs and isinstance #74690
Closed
warsaw pushed a commit to warsaw/cpython that referenced this pull request Apr 11, 2023
@AlexWaygood @warsaw
pythongh-102936: typing: document performance pitfalls of protocols d…
0933b35
…ecorated with `@runtime_checkable` (python#102937)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Reviewers

@gvanrossum gvanrossum gvanrossum approved these changes
@hauntsaninja hauntsaninja hauntsaninja approved these changes
@furkanonder furkanonder furkanonder approved these changes
@Fidget-Spinner Fidget-Spinner Awaiting requested review from Fidget-Spinner
@JelleZijlstra JelleZijlstra Awaiting requested review from JelleZijlstra JelleZijlstra is a code owner

Uh oh!

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

Assignees

No one assigned

Labels

docs Documentation in the Doc dir skip news topic-typing

Projects

None yet

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.

6 participants

@AlexWaygood @miss-islington @bedevere-bot @gvanrossum @hauntsaninja @furkanonder
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.