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

2015-02-19 Thread Craig Holmquist
Craig Holmquist added the comment: It seems like performance is drastically improved by doing this: class Category(Enum): tiny = 1 medium = 2 large = 3 tiny = Category.tiny medium = Category.medium In other words, resolving Category.tiny and Category.medium is what's slow. The co

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

2015-02-19 Thread Craig Holmquist
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 =

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

2015-02-19 Thread Ethan Furman
Ethan Furman added the comment: Craig Holmquist wrote: - > The consumer of that iteration processes each object with a switch-case-like > comparison of the category, checking it sequentially against each instance > of the Enum. So for every object you compare against every En

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

2015-02-19 Thread Ethan Furman
Changes by Ethan Furman : -- nosy: +ethan.furman ___ Python tracker ___ ___ Python-bugs-list mailing list Unsubscribe: https://mail.p

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

2015-02-19 Thread Craig Holmquist
New submission from Craig Holmquist: Running the attached test script: $ time python test.py enum real0m6.546s user0m6.530s sys 0m0.007s $ time python test.py int real0m0.384s user0m0.377s sys 0m0.000s I encountered this with a script that yielded a sequence of objects