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-102213: Optimize the performance of `__getattr__` by sunmy2019 · Pull Request #103761 · python/cpython

Conversation

@sunmy2019

@sunmy2019 sunmy2019 commented Apr 24, 2023 •
edited by bedevere-bot
Loading

Uh oh!

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

Copy link
Copy Markdown
Member

This is the logically corrected version of GH-102248.

GH-102248 caused several issues and had been reverted. This PR (I think) correctly implements it.

Tests passed on Ubuntu 22.04 (WSL) gcc-11 with --pydebug.

I also do the perf tests in the original PR, (--enable-optimizations with my AMD 5900X)
Before,

Python version of 3.12.0a7+ (heads/gh-102248-corrected:af53046995, Apr 24 2023, 22:42:22) [GCC 11.3.0]
Call __getattr__ spend time: 0.2576024532318115

After,

Python version of 3.12.0a7+ (heads/gh-102248-corrected:ac81fd6c7e, Apr 24 2023, 22:39:39) [GCC 11.3.0]
Call __getattr__ spend time: 0.04635906219482422

cc: @Fidget-Spinner

  • Issue: Improve the Efficiency of Python3.11.1 __getattr__ #102213

Sorry, something went wrong.

Uh oh!

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

Eclips4, Fidget-Spinner, and wangxiang-hz reacted with thumbs up emoji
All reactions
  • 👍 3 reactions
@sunmy2019
Optimize the performance of __getattr__
ac81fd6
This is the corrected version of pythonGH-102248
@sunmy2019
sunmy2019 requested a review from markshannon as a code owner April 24, 2023 14:44
@bedevere-bot bedevere-bot added the awaiting review label Apr 24, 2023
Eclips4
Eclips4 reviewed Apr 24, 2023
View reviewed changes
Comment thread Objects/typeobject.c Resolved

Uh oh!

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

@sunmy2019 @Eclips4
Update Objects/typeobject.c
f6c3704
Co-authored-by: Kirill <[email protected]>
sunmy2019
sunmy2019 commented Apr 24, 2023
View reviewed changes
Comment thread Objects/typeobject.c Resolved

Uh oh!

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

@sunmy2019
Update Objects/typeobject.c
91aa490
@sunmy2019 sunmy2019 changed the title Optimize the performance of __getattr__ gh-102213: Optimize the performance of __getattr__ Apr 24, 2023
@bedevere-bot bedevere-bot mentioned this pull request Apr 24, 2023
Improve the Efficiency of Python3.11.1 __getattr__ #102213
Closed
@Fidget-Spinner

Fidget-Spinner commented Apr 24, 2023

Copy link
Copy Markdown
Member

Note to myself or whoever who merges this. Please add @wangxiang-hz to co-authors when merging as this is the fixed version of their PR, and the work should also be attributed to them.

All reactions

Sorry, something went wrong.

Uh oh!

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

@Fidget-Spinner

Fidget-Spinner commented Apr 24, 2023

Copy link
Copy Markdown
Member

I will review and hopefully merge this on Friday when I have more time. Thanks.

All reactions

Sorry, something went wrong.

Uh oh!

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

@Fidget-Spinner Fidget-Spinner self-assigned this Apr 24, 2023
@bluetech

bluetech commented Apr 24, 2023

Copy link
Copy Markdown
Contributor

#103551 has a simple test case for the issue with the original PR, might be useful to add as a unit test for this PR.

All reactions

Sorry, something went wrong.

Uh oh!

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

@ambv
Merge branch 'main' into pythongh-102248-corrected
c90be9d
@sunmy2019

sunmy2019 commented Apr 25, 2023

Copy link
Copy Markdown
Member Author

#103551 has a simple test case for the issue with the original PR, might be useful to add as a unit test for this PR.

@property raises and __getattr__ not called --> added in #103358
@property calls __getattr__, and __getattr__ raises --> added in #103336

The test of #103551 should be covered by #103358. But a little duplication is okay. I will add it later.

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

Sorry, something went wrong.

Uh oh!

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

@sunmy2019
add test case for pythongh-103551
c3aebf6
Fidget-Spinner
Fidget-Spinner reviewed Apr 27, 2023
View reviewed changes
Comment thread Objects/typeobject.c Resolved

Uh oh!

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

@Fidget-Spinner Fidget-Spinner added the 🔨 test-with-buildbots Test PR w/ buildbots; report in status section label Apr 27, 2023
@bedevere-bot

bedevere-bot commented Apr 27, 2023

Copy link
Copy Markdown

🤖 New build scheduled with the buildbot fleet by @Fidget-Spinner for commit c3aebf6 🤖

If you want to schedule another build, you need to add the 🔨 test-with-buildbots label again.

All reactions

Sorry, something went wrong.

Uh oh!

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

@bedevere-bot bedevere-bot removed the 🔨 test-with-buildbots Test PR w/ buildbots; report in status section label Apr 27, 2023
@sunmy2019
Update Objects/typeobject.c
75d9a70
@sunmy2019

sunmy2019 commented Apr 27, 2023 •
edited
Loading

Uh oh!

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

Copy link
Copy Markdown
Member Author

Does anyone have any idea why this fails?
https://buildbot.python.org/all/#/builders/738/builds/3112
The failure is a timing test. This PR seems to have changed the time usage of one particular test on ARM.

Got a timeout here: https://buildbot.python.org/all/#/builders/403/builds/1066

all builds: https://buildbot.python.org/all/#/changes/22158

All reactions

Sorry, something went wrong.

Uh oh!

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

@Fidget-Spinner

Fidget-Spinner commented Apr 28, 2023

Copy link
Copy Markdown
Member

Got a timeout here: https://buildbot.python.org/all/#/builders/403/builds/1066

This specific test seems flaky. I would ignore it.

All reactions

Sorry, something went wrong.

Uh oh!

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

@sunmy2019

sunmy2019 commented Apr 30, 2023 •
edited
Loading

Uh oh!

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

Copy link
Copy Markdown
Member Author

@Fidget-Spinner How is it going on? We are running out of time. New features will soon be frozen in May. 7th.
https://peps.python.org/pep-0693/

Or will this be considered as a bug fix?

All reactions

Sorry, something went wrong.

Uh oh!

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

@Fidget-Spinner Fidget-Spinner added the 🔨 test-with-buildbots Test PR w/ buildbots; report in status section label Apr 30, 2023
@bedevere-bot

bedevere-bot commented Apr 30, 2023

Copy link
Copy Markdown

🤖 New build scheduled with the buildbot fleet by @Fidget-Spinner for commit 75d9a70 🤖

If you want to schedule another build, you need to add the 🔨 test-with-buildbots label again.

All reactions

Sorry, something went wrong.

Uh oh!

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

@bedevere-bot bedevere-bot removed the 🔨 test-with-buildbots Test PR w/ buildbots; report in status section label Apr 30, 2023
@Fidget-Spinner

Fidget-Spinner commented Apr 30, 2023

Copy link
Copy Markdown
Member

@Fidget-Spinner How is it going on? We are running out of time. New features will soon be frozen in May. 7th. https://peps.python.org/pep-0693/

Or will this be considered as a bug fix?

I'm triggering a buildbot rerun to see if that specific buildbot is actually impacted.

All reactions

Sorry, something went wrong.

Uh oh!

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

@sunmy2019

sunmy2019 commented May 1, 2023

Copy link
Copy Markdown
Member Author

https://buildbot.python.org/all/#builders/178/builds/1189

test_monitoring failure is tracked here
#103845
test_import failure is tracked here
#103879 (comment)

Seems no more failures

All reactions

Sorry, something went wrong.

Uh oh!

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

@Fidget-Spinner

Fidget-Spinner commented May 1, 2023

Copy link
Copy Markdown
Member

Please add news. You can copy the previous PR's news item. I will attribute the commit to both of you.

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

Sorry, something went wrong.

Uh oh!

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

@Fidget-Spinner
Fidget-Spinner removed request for 1st1, AlexWaygood, JelleZijlstra, abalkin, asvetlov, brandtbucher, corona10, encukou, ericsnowcurrently, ericvsmith, erlend-aasland, ethanfurman, ezio-melotti, gvanrossum, hugovk, iritkatriel, kumaraditya303, lysnikolaou, ncoghlan, pablogsal, pganssle, rhettinger, terryjreedy, vsajip, warsaw and willingc May 1, 2023 09:27
@Fidget-Spinner
Fidget-Spinner merged commit 59c27fa into python:main May 1, 2023
@bedevere-bot bedevere-bot removed the awaiting review label May 1, 2023
@arhadthedev

arhadthedev commented May 1, 2023

Copy link
Copy Markdown
Member

Please, don't worry about 229 random files reported as changed. It's a GitHub after-merge artifact, the final commit 59c27fa squash-merged into main is fine.

All reactions

Sorry, something went wrong.

Uh oh!

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

@wangxiang-hz

wangxiang-hz commented May 4, 2023

Copy link
Copy Markdown
Contributor

Sorry guys, I just noticed this pull request. I was buy with my work these weeks and just finished a major update at the end of April..
I think @sunmy2019 is right and his commits is better. call_attribute should only be called when attribute is not found, then we call it, and clear the PyExc_AttributeError being raised.
I made a mistake, PyObject_GenericGetAttr may not raise attribute error but other scripts may still raise other exceptions. When this happen, call_attribute should not be called.
Thank you all for finding this and sorry for the bugs triggered.

Fidget-Spinner and sunmy2019 reacted with thumbs up emoji Fidget-Spinner reacted with heart emoji
All reactions
  • 👍 2 reactions
  • ❤️ 1 reaction

Sorry, something went wrong.

Uh oh!

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

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Reviewers

@Fidget-Spinner Fidget-Spinner Fidget-Spinner left review comments
@Eclips4 Eclips4 Eclips4 left review comments
@markshannon markshannon Awaiting requested review from markshannon markshannon is a code owner

Uh oh!

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

Assignees

@Fidget-Spinner Fidget-Spinner

Labels

None yet

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.

8 participants

@sunmy2019 @Fidget-Spinner @bluetech @bedevere-bot @arhadthedev @wangxiang-hz @Eclips4 @ambv
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.