◐ Shell
clean mode source ↗

[WIP] bpo-27535: Optimize warnings by vstinner · Pull Request #4502 · python/cpython

added 4 commits

November 22, 2017 00:48
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()

@ghost ghost mentioned this pull request

Sep 12, 2022