[issue27935] logging level FATAL missing in _nameToLevel
New submission from Ondřej Medek: logging.__init__._nameToLevel is missing 'FATAL' key: >>> logging.getLevelName('FATAL') 'Level FATAL' Expected same as: >>> logging.getLevelName('CRITICAL') 50 ------ components: Library (Lib) messages: 274204 nosy: Ondřej Medek priority: normal severity: normal status: open title: logging level FATAL missing in _nameToLevel type: behavior versions: Python 3.5 ___ Python tracker <http://bugs.python.org/issue27935> ___ ___ Python-bugs-list mailing list Unsubscribe: https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[issue27937] logging.getLevelName microoptimization
New submission from Ondřej Medek: The logging.getLevelName contains code: return _levelToName.get(level, _nameToLevel.get(level, ("Level %s" % level))) I am still a Python beginner, but I think the most of the times the _nameToLevel.get is called unnecessarily. IMHO the code should be return _levelToName.get(level, (_nameToLevel.get(level, ("Level %s" % level or maybe better a classic if then style: result = _levelToName.get(level) if result is None: result = _nameToLevel.get(level, ("Level %s" % level)) return result Since this function is called every time the LogRecord is created, I think it should be microoptimized. -- components: Library (Lib) messages: 274210 nosy: Ondřej Medek priority: normal severity: normal status: open title: logging.getLevelName microoptimization type: performance versions: Python 3.5 ___ Python tracker <http://bugs.python.org/issue27937> ___ ___ Python-bugs-list mailing list Unsubscribe: https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[issue27937] logging.getLevelName microoptimization
Ondřej Medek added the comment: Which 'first' method do you mean? logging.getLevelName() converts level (int) to level name (str). But due to the backward compatibility is also converts level name (str) to level (int). -- ___ Python tracker <http://bugs.python.org/issue27937> ___ ___ Python-bugs-list mailing list Unsubscribe: https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[issue27937] logging.getLevelName microoptimization
Ondřej Medek added the comment: That's probably my lack of Python knowledge. I have though that parentheses in ("Level %s" % level) cause lazy evaluation. If not, then this code has to be optimized by if-then, too. -- ___ Python tracker <http://bugs.python.org/issue27937> ___ ___ Python-bugs-list mailing list Unsubscribe: https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[issue27935] logging level FATAL missing in _nameToLevel
Ondřej Medek added the comment: Just a comment to the https://hg.python.org/cpython/rev/85f9f8bf2ec8 It's functionality is right. It's just a little bit weird, that two derived levels in _nameToLevel: 'FATAL' maps to FATAL, i.e. itself, while 'WARN' maps to the WARNING, i.e. to the main level from which is derived. -- ___ Python tracker <http://bugs.python.org/issue27935> ___ ___ Python-bugs-list mailing list Unsubscribe: https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com