This issue tracker has been migrated to GitHub, and is currently read-only.
For more information, see the GitHub FAQs in the Python's Developer Guide.

classification
Title: logging.Logger.disabled field is redundant
Type: performance Stage: resolved
Components: Library (Lib) Versions: Python 3.9, Python 3.8, Python 3.7, Python 3.6, Python 3.5
process
Status: closed Resolution: not a bug
Dependencies: Superseder:
Assigned To: Nosy List: rvprasad
Priority: normal Keywords:

Created on 2020-03-19 16:48 by rvprasad, last changed 2022-04-11 14:59 by admin. This issue is now closed.

Messages (2)
msg364612 - (view) Author: Venkatesh-Prasad Ranganath (rvprasad) Date: 2020-03-19 16:48
`logging.Logger.disabled` field is assigned `False` while initializing `logging.Logger` instance and never updated.  However, this field is also involved in two checks: https://github.com/python/cpython/blob/da1fe768e582387212201ab8737a1a5f26110664/Lib/logging/__init__.py#L1586 and https://github.com/python/cpython/blob/da1fe768e582387212201ab8737a1a5f26110664/Lib/logging/__init__.py#L1681 that are executed in the context of every logging method.  So, these checks are likely to contribute to unnecessary computation while logging.

Further, since the library documentation does not mention this field, the field is probably not part of the public API of the logging library.  So, the field seems to be redundant.

Given the checks on the hot paths are redundant as the field never changes value and fields is not part of the public API, removing it will help improve logging performance and simplify the code base.
msg364614 - (view) Author: Venkatesh-Prasad Ranganath (rvprasad) Date: 2020-03-19 17:00
`logging.Logger.disabled` field is used in logging.config module to disable loggers during configuration.  Since the field is not redundant, the issue is invalid and, hence, should be closed.
History
Date User Action Args
2022-04-11 14:59:28adminsetgithub: 84196
2020-03-19 17:00:07rvprasadsetstatus: open -> closed
versions: + Python 3.5, Python 3.6, Python 3.7, Python 3.9
messages: + msg364614

resolution: not a bug
stage: resolved
2020-03-19 16:48:06rvprasadcreate