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-74690: Document changes made to runtime-checkable protocols in 3.12 by AlexWaygood · Pull Request #103348 · python/cpython

Conversation

@AlexWaygood

@AlexWaygood AlexWaygood commented Apr 7, 2023 •
edited
Loading

Uh oh!

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

Copy link
Copy Markdown
Member

Adds docs, NEWS and WhatsNew entries for changes made in these PRs:

  • gh-74690: typing: Don't unnecessarily call _get_protocol_attrs twice in _ProtocolMeta.__instancecheck__ #103141
  • gh-74690: Micro-optimise typing._get_protocol_attrs #103152
  • gh-74690: typing: Simplify and optimise _ProtocolMeta.__instancecheck__ #103159
  • gh-74690: typing: Call _get_protocol_attrs and _callable_members_only at protocol class creation time, not during isinstance() checks #103160
  • gh-74690: Further optimise typing._ProtocolMeta.__instancecheck__ #103280
  • gh-103193: Micro-optimise helper functions for inspect.getattr_static #103195
  • gh-103193: Use LBYL idioms rather than EAFP in inspect.getattr_static #103318
  • gh-103193: Speedup and inline inspect._is_type #103321
  • Issue: Performance of typing._ProtocolMeta._get_protocol_attrs and isinstance #74690

Sorry, something went wrong.

Uh oh!

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

All reactions
@AlexWaygood
pythongh-74690: Document changes made to runtime-checkable protocols …
4558ee1
…in Python 3.12
@bedevere-bot bedevere-bot added the docs Documentation in the Doc dir label Apr 7, 2023
@bedevere-bot bedevere-bot mentioned this pull request Apr 7, 2023
Performance of typing._ProtocolMeta._get_protocol_attrs and isinstance #74690
Closed
@bedevere-bot bedevere-bot added the awaiting core review label Apr 7, 2023
@AlexWaygood AlexWaygood added the topic-typing label Apr 7, 2023
AlexWaygood added 2 commits April 7, 2023 15:24
@AlexWaygood
Fix markup
46fd03b
@AlexWaygood
Fix markup
8cc89d7
@AlexWaygood
AlexWaygood marked this pull request as ready for review April 7, 2023 14:30
@AlexWaygood
AlexWaygood requested review from Fidget-Spinner, JelleZijlstra and gvanrossum as code owners April 7, 2023 14:30
@AlexWaygood
AlexWaygood requested review from carljm and hauntsaninja April 7, 2023 14:30
AlexWaygood added 2 commits April 7, 2023 15:32
@AlexWaygood
Make sphinx-lint happy
216b875
@AlexWaygood
Sync whatsnew
713fbf8
@AlexWaygood AlexWaygood added the 3.12 only security fixes label Apr 7, 2023
carljm
carljm approved these changes Apr 7, 2023
View reviewed changes
Comment thread Doc/library/typing.rst Resolved

Uh oh!

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

@bedevere-bot bedevere-bot added awaiting merge and removed awaiting core review labels Apr 7, 2023
@AlexWaygood AlexWaygood linked an issue Apr 7, 2023 that may be closed by this pull request
Performance of typing._ProtocolMeta._get_protocol_attrs and isinstance #74690
Closed
AlexWaygood added 2 commits April 7, 2023 20:06
@AlexWaygood
Address review: make more concise
7e4410c
@AlexWaygood
Fix markup
22de854
CAM-Gerlach
CAM-Gerlach reviewed Apr 7, 2023
View reviewed changes
Comment thread Misc/NEWS.d/next/Library/2023-04-07-15-09-26.gh-issue-74690.0f886b.rst Resolved

Uh oh!

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

JelleZijlstra
JelleZijlstra reviewed Apr 7, 2023
View reviewed changes
Comment thread Misc/NEWS.d/next/Library/2023-04-07-15-09-26.gh-issue-74690.0f886b.rst Resolved

Uh oh!

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

@JelleZijlstra
Update Misc/NEWS.d/next/Library/2023-04-07-15-09-26.gh-issue-74690.0f…
18e1f74
…886b.rst
JelleZijlstra
JelleZijlstra approved these changes Apr 7, 2023
View reviewed changes
hauntsaninja
hauntsaninja approved these changes Apr 7, 2023
View reviewed changes

@hauntsaninja hauntsaninja left a comment •
edited
Loading

Uh oh!

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

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.

The changes look good. Only thing I'm thinking of is that most users reading What's New still don't have the context that runtime_checkable isinstance is like 400x slower than regular isinstance or whatever. Feels hard to communicate "this thing is 20x faster than it was, but is still 20x slower than you might think it is", but maybe there's a good way :-)

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 commented Apr 7, 2023

Copy link
Copy Markdown
Member Author

Only thing I'm thinking of is that most users reading What's New still don't have the context that runtime_checkable isinstance is like 400x slower than regular isinstance or whatever.

Well, only ~15x slower in 3.12 for simple protocols ;)

Feels hard to communicate "this thing is 20x faster than it was, but is still 20x slower than you might think it is"

Yeah... I know what you mean. I feel pretty torn. On the one hand, I agree that this is important context. On the other hand, I feel like this is pretty clearly documented in typing.rst now; that the performance improvement is worth celebrating on its own; and that "What's new" should be primarily focussed on the difference between the Python versions.

I think I'll leave this as it is for now, but happy to accept improvements in followup PRs if we can think of a better way of phrasing it :-)

All reactions

Sorry, something went wrong.

Uh oh!

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

@AlexWaygood
AlexWaygood merged commit 6441365 into python:main Apr 7, 2023
@bedevere-bot bedevere-bot removed the awaiting merge label Apr 7, 2023
@AlexWaygood
AlexWaygood deleted the document-runtime-protocol-changes branch April 7, 2023 21:06
@AlexWaygood AlexWaygood mentioned this pull request Apr 10, 2023
Lack of space after Sphinx role not detected sphinx-contrib/sphinx-lint#60
Closed
warsaw pushed a commit to warsaw/cpython that referenced this pull request Apr 11, 2023
@AlexWaygood @JelleZijlstra @warsaw
pythongh-74690: Document changes made to runtime-checkable protocols …
ce6c245
…in 3.12 (python#103348)

Co-authored-by: Jelle Zijlstra <[email protected]>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Reviewers

@JelleZijlstra JelleZijlstra JelleZijlstra approved these changes
@CAM-Gerlach CAM-Gerlach CAM-Gerlach left review comments
@carljm carljm carljm approved these changes
@hauntsaninja hauntsaninja hauntsaninja approved these changes
@gvanrossum gvanrossum Awaiting requested review from gvanrossum
@Fidget-Spinner Fidget-Spinner Awaiting requested review from Fidget-Spinner

Uh oh!

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

Assignees

No one assigned

Labels

3.12 only security fixes docs Documentation in the Doc dir topic-typing

Projects

None yet

Milestone

No milestone

Development

Successfully merging this pull request may close these issues.

Performance of typing._ProtocolMeta._get_protocol_attrs and isinstance

Uh oh!

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

6 participants

@AlexWaygood @carljm @JelleZijlstra @hauntsaninja @CAM-Gerlach @bedevere-bot
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.