◐ Shell
reader mode source ↗
Skip to content

bpo-27535: Optimize warnings.warn()#4508

Merged
vstinner merged 1 commit into
python:masterfrom
vstinner:warn_optim2
Nov 22, 2017
Merged

bpo-27535: Optimize warnings.warn()#4508
vstinner merged 1 commit into
python:masterfrom
vstinner:warn_optim2

Conversation

@vstinner

@vstinner vstinner commented Nov 22, 2017

Copy link
Copy Markdown
Member
  • 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().

Cleanup also create_filter():

  • Use _Py_IDENTIFIER() to allow to cleanup strings at Python
    finalization
  • Replace Py_FatalError() with a regular exceptions

https://bugs.python.org/issue27535

* 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().

Cleanup also create_filter():

* Use _Py_IDENTIFIER() to allow to cleanup strings at Python
  finalization
* Replace Py_FatalError() with a regular exceptions
@vstinner vstinner merged commit 8265627 into python:master Nov 22, 2017
@vstinner vstinner deleted the warn_optim2 branch November 22, 2017 22:51
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants