[New-bugs-announce] [issue35585] Speedup Enum lookup

Andrew Svetlov report at bugs.python.org
Tue Dec 25 19:26:24 EST 2018


New submission from Andrew Svetlov <andrew.svetlov at gmail.com>:

Construction enums by-value (e.g. http.HTTPStatus(200)) performs two dict lookups: 
    if value in cls._value2member_map_:
        return cls._value2member_map_[value]

Changing the code to just
    return cls._value2member_map_[value]
with catching KeyError can speedup the fast path a little.

----------
components: Library (Lib)
messages: 332524
nosy: asvetlov
priority: normal
severity: normal
status: open
title: Speedup Enum lookup
versions: Python 3.7, Python 3.8

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


More information about the New-bugs-announce mailing list