[WIP] bpo-27535: Optimize warnings#4502
Closed
vstinner wants to merge 4 commits intopython:masterfrom
vstinner:warn_optim
Closed
[WIP] bpo-27535: Optimize warnings#4502vstinner wants to merge 4 commits intopython:masterfrom vstinner:warn_optim
vstinner wants to merge 4 commits intopython:masterfrom
vstinner:warn_optim
Conversation
The warnings module doesn't leak memory anymore in the hidden warnings registry for the "ignore" action of warnings filters. The warn_explicit() function doesn't add the warning key to the registry anymore for the "ignore" action.
* Optimize warnings.filterwarnings(). Replace re.compile('') with
None to avoid the cost of calling a regex.match() method, whereas
it always matchs.
* Optimize get_warnings_attr(): replace PyObject_GetAttrString() with
_PyObject_GetAttrId().
Make it more explicit that warnings.filters must not be replaced directly, but modified by: * filterwarning() * simplefilter() * resetwarnings()
Member
Author
|
Oh, the latest commit "warnings.filters becomes an immutable tuple" broke regrtest --huntrefleak: |
Member
Author
|
While the speedup is interesting, these changes are backward incompatible and I'm not sure that it's acceptable. I prefer to close my PR. |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
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.
https://bugs.python.org/issue27535