[New-bugs-announce] [issue40015] logging.Logger.disabled field is redundant

Venkatesh-Prasad Ranganath report at bugs.python.org
Thu Mar 19 12:48:06 EDT 2020


New submission from Venkatesh-Prasad Ranganath <rvprasad.free at gmail.com>:

`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.

----------
components: Library (Lib)
messages: 364612
nosy: rvprasad
priority: normal
severity: normal
status: open
title: logging.Logger.disabled field is redundant
type: performance
versions: Python 3.8

_______________________________________
Python tracker <report at bugs.python.org>
<https://bugs.python.org/issue40015>
_______________________________________


More information about the New-bugs-announce mailing list