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-137855: Optimise import time for textwrap by AA-Turner · Pull Request #131956 · python/cpython Conversation
|
Happy to, do you mean for A |
Sorry, something went wrong.
There was an error while loading. Please reload this page.
|
I think tests with accessing / resetting / deleting the attributes (they are publicly named even though they are not exposed, just in case someone is subclassing them [again they shouldn't be part of the public API but well.. you never know; and it would be good to just check that the patterns are the expected ones. But yes, also a small test for the descriptor with a fake pattern and check that its implementation is correct (well it should be AFAIK). |
Sorry, something went wrong.
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.
I'm not excited by this change, IMO it goes too far :-(
This change is an optimization, you should provide a benchmark to prove that the change is worth it.
Sorry, something went wrong.
There was an error while loading. Please reload this page.
There was an error while loading. Please reload this page.
@vstinner sorry for not including them. Benchmarks show a consistent large decrease in import time, around 10ms on a standard release build in Windows. See below for detailed numbers: Using Old: The same command, on the default Old: With hyperfine, Python 3.13.2: A |
Sorry, something went wrong.
There was an error while loading. Please reload this page.
There was an error while loading. Please reload this page.
Sorry, something went wrong.
There was an error while loading. Please reload this page.
|
This PR is stale because it has been open for 30 days with no activity. |
Sorry, something went wrong.
There was an error while loading. Please reload this page.
|
Can this change be made simpler by using |
Sorry, something went wrong.
There was an error while loading. Please reload this page.
I don't think so as the class body of the textwrap class will be executed at import time, so |
Sorry, something went wrong.
There was an error while loading. Please reload this page.
| whitespace = r'[%s]' % re.escape(_whitespace) | ||
| nowhitespace = '[^' + whitespace[1:] | ||
| wordsep_re = re.compile(r''' | ||
| whitespace = fr'[{_whitespace}]' |
There was a problem hiding this comment.
The reason will be displayed to describe this comment to others. Learn more.
Half of this PR is code refactoring which makes the PR harder to review. I would prefer to have a separated PR just for the refactoring.
Sorry, something went wrong.
There was an error while loading. Please reload this page.
| __all__ = ['TextWrapper', 'wrap', 'fill', 'dedent', 'indent', 'shorten'] | ||
|
|
||
|
|
||
| class _cached_regex: |
There was a problem hiding this comment.
The reason will be displayed to describe this comment to others. Learn more.
Can you add a comment explaining the purpose of this class (lazy import)?
Sorry, something went wrong.
There was an error while loading. Please reload this page.
|
This PR is stale because it has been open for 90 days with no activity. |
Sorry, something went wrong.
There was an error while loading. Please reload this page.
…h-137855) Co-authored-by: Muse Code (Meta Muse Spark)
|
@AA-Turner: Are you still working on this PR? It's mostly idle for a few months. Maybe it should just be closed? |
Sorry, something went wrong.
There was an error while loading. Please reload this page.
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.