[issue23486] Enum comparisons are 20x slower than comparing equivalent ints

Craig Holmquist report at bugs.python.org
Thu Feb 19 23:19:34 CET 2015


Craig Holmquist added the comment:

I may not have been clear before.  What I mean is, code like this:

for obj in get_objects():
    if obj.category == Cat.cat1:
        #do something
    elif obj.category == Cat.cat2:
        #do something else
    elif obj.category == Cat.cat3 or obj.category == Cat.cat4:
        #...

obj.category is already an instance of Cat, in other words.  The consumer is using it to determine what to do with each obj.

----------

_______________________________________
Python tracker <report at bugs.python.org>
<http://bugs.python.org/issue23486>
_______________________________________


More information about the Python-bugs-list mailing list