GeezerVisonThe World Wide Web, restored to 800 pixels of glory. | |||||||||
| Home|About|Gaming cabinet|Archives|How it works|Starter sites | |||||||||
GeezerVison is showing github.com — gh-102302 Micro-optimize `inspect.Parameter.__hash__` by Gouvernathor · Pull Request #102303 · python/cpython Conversation
|
|
Closing; see discussion on the issue for the rationale |
Sorry, something went wrong.
There was an error while loading. Please reload this page.
|
I still think that this is a good idea: using properties here does not make any practical sense. And direct attribute access is slightly faster. |
Sorry, something went wrong.
There was an error while loading. Please reload this page.
|
If somebody can give a benchmark showing a meaningful performance improvement here, I'm happy to reconsider, but the motivation put forward in the issue was not primarily to do with performance. I don't find the rationale in the issue convincing, and I also don't consider an argument to do with "consistency" a strong enough reason to make a change to the stdlib. This doesn't really fix anything I'd consider a user-visible bug (and if it does, it needs a test/NEWS), so I can't see how it's worth the code churn. |
Sorry, something went wrong.
There was an error while loading. Please reload this page.
There was an error while loading. Please reload this page.
|
@AlexWaygood here are my micro-benchmarks. Old code ( New code ( I think that the speed-up is quite big for just 4 chars of code :) |
Sorry, something went wrong.
There was an error while loading. Please reload this page.
There was an error while loading. Please reload this page.
There was a problem hiding this comment.
The reason will be displayed to describe this comment to others. Learn more.
Please add a short news entry describing the impact this patch will have on users of inspect. Something like this should suffice:
Micro-optimise ``inspect.Parameter.__hash__``, reducing the time it takes to hash an instance by around 40%.
Sorry, something went wrong.
There was an error while loading. Please reload this page.
|
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 |
Sorry, something went wrong.
There was an error while loading. Please reload this page.
|
So, my overriding the default property will happen to work in the next version, but not be considered a documented feature and could break in future versions without warning ? Just asking to be sure we're on the same page. |
Sorry, something went wrong.
There was an error while loading. Please reload this page.
There was an error while loading. Please reload this page.
Correct -- I'm happy to accept this patch on the basis of the microbenchmark @sobolevn provided, but I still wouldn't recommend doing what you're currently doing in your code base :) Something along the lines of what I suggested in #102302 (comment) would be safer and less prone to inadvertent breakage. |
Sorry, something went wrong.
There was an error while loading. Please reload this page.
|
Judging from this, the :class: should work. |
Sorry, something went wrong.
There was an error while loading. Please reload this page.
inspect.Parameter.__hash__
There was a problem hiding this comment.
The reason will be displayed to describe this comment to others. Learn more.
Thanks for the patch, and thanks @sobolevn for persuading me to change my mind :)
Sorry, something went wrong.
There was an error while loading. Please reload this page.
|
🎉 |
Sorry, something went wrong.
There was an error while loading. Please reload this page.
* main: (21 commits) pythongh-102192: Replace PyErr_Fetch/Restore etc by more efficient alternatives in sub interpreters module (python#102472) pythongh-95672: Fix versionadded indentation of get_pagesize in test.rst (pythongh-102455) pythongh-102416: Do not memoize incorrectly loop rules in the parser (python#102467) pythonGH-101362: Optimise PurePath(PurePath(...)) (pythonGH-101667) pythonGH-101362: Check pathlib.Path flavour compatibility at import time (pythonGH-101664) pythonGH-101362: Call join() only when >1 argument supplied to pathlib.PurePath() (python#101665) pythongh-102444: Fix minor bugs in `test_typing` highlighted by pyflakes (python#102445) pythonGH-102341: Improve the test function for pow (python#102342) Fix unused classes in a typing test (pythonGH-102437) pythongh-101979: argparse: fix a bug where parentheses in metavar argument of add_argument() were dropped (python#102318) pythongh-102356: Add thrashcan macros to filter object dealloc (python#102426) Move around example in to_bytes() to avoid confusion (python#101595) pythonGH-97546: fix flaky asyncio `test_wait_for_race_condition` test (python#102421) pythongh-96821: Add config option `--with-strict-overflow` (python#96823) pythongh-101992: update pstlib module documentation (python#102133) pythongh-63301: Set exit code when tabnanny CLI exits on error (python#7699) pythongh-101863: Fix wrong comments in EUC-KR codec (pythongh-102417) pythongh-102302 Micro-optimize `inspect.Parameter.__hash__` (python#102303) pythongh-102179: Fix `os.dup2` error reporting for negative fds (python#102180) pythongh-101892: Fix `SystemError` when a callable iterator call exhausts the iterator (python#101896) ...
* main: (37 commits) pythongh-102192: Replace PyErr_Fetch/Restore etc by more efficient alternatives in sub interpreters module (python#102472) pythongh-95672: Fix versionadded indentation of get_pagesize in test.rst (pythongh-102455) pythongh-102416: Do not memoize incorrectly loop rules in the parser (python#102467) pythonGH-101362: Optimise PurePath(PurePath(...)) (pythonGH-101667) pythonGH-101362: Check pathlib.Path flavour compatibility at import time (pythonGH-101664) pythonGH-101362: Call join() only when >1 argument supplied to pathlib.PurePath() (python#101665) pythongh-102444: Fix minor bugs in `test_typing` highlighted by pyflakes (python#102445) pythonGH-102341: Improve the test function for pow (python#102342) Fix unused classes in a typing test (pythonGH-102437) pythongh-101979: argparse: fix a bug where parentheses in metavar argument of add_argument() were dropped (python#102318) pythongh-102356: Add thrashcan macros to filter object dealloc (python#102426) Move around example in to_bytes() to avoid confusion (python#101595) pythonGH-97546: fix flaky asyncio `test_wait_for_race_condition` test (python#102421) pythongh-96821: Add config option `--with-strict-overflow` (python#96823) pythongh-101992: update pstlib module documentation (python#102133) pythongh-63301: Set exit code when tabnanny CLI exits on error (python#7699) pythongh-101863: Fix wrong comments in EUC-KR codec (pythongh-102417) pythongh-102302 Micro-optimize `inspect.Parameter.__hash__` (python#102303) pythongh-102179: Fix `os.dup2` error reporting for negative fds (python#102180) pythongh-101892: Fix `SystemError` when a callable iterator call exhausts the iterator (python#101896) ...
There was an error while loading. Please reload this page.
Successfully merging this pull request may close these issues.
There was an error while loading. Please reload this page.