(original) (raw)

Anyway, if you're doing arithmetic on enums you're doing it wrong.

Sent from Mailbox


On Sun, May 19, 2013 at 4:55 AM, Nick Coghlan <ncoghlan@gmail.com> wrote:

On Sun, May 19, 2013 at 4:41 PM, Raymond Hettinger
wrote:
> nicer repr" is worth "Sorry, I broke your tests, made your published
> examples
> out of date, and slowed down your code."

While the first two considerations are always potentially applicable
when using enums, the latter should only be true for code that uses
str() and repr() a lot. For other operations, int-based enums
shouldn't add any more overhead than namedtuple does for tuples.

I agree with basically everything you said, but I don't want "enums
are slower than normal integers" to become a meme - there really
shouldn't be a speed difference for any arithmetic operations when
using IntEnum.

Cheers,
Nick.

--
Nick Coghlan | ncoghlan@gmail.com | Brisbane, Australia
\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_
Python-Dev mailing list
Python-Dev@python.org
http://mail.python.org/mailman/listinfo/python-dev
Unsubscribe: http://mail.python.org/mailman/options/python-dev/guido%40python.org