[Python-Dev] Purpose of Doctests [Was: Best practices for Enum] (original) (raw)
Nick Coghlan ncoghlan at gmail.com
Mon May 20 02:24:08 CEST 2013
- Previous message: [Python-Dev] Purpose of Doctests [Was: Best practices for Enum]
- Next message: [Python-Dev] Purpose of Doctests [Was: Best practices for Enum]
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]
On Mon, May 20, 2013 at 10:14 AM, Antoine Pitrou <solipsis at pitrou.net> wrote:
On Sun, 19 May 2013 20:04:03 -0400 Ned Batchelder <ned at nedbatchelder.com> wrote:
On 5/19/2013 7:22 PM, Mark Janssen wrote: > On Sun, May 19, 2013 at 1:13 PM, Tres Seaver <tseaver at palladion.com> wrote: >> -----BEGIN PGP SIGNED MESSAGE----- >> Hash: SHA1 >> >> On 05/19/2013 10:48 AM, Guido van Rossum wrote: >>> Anyway, if you're doing arithmetic on enums you're doing it wrong. >> Hmm, bitwise operations, even? > I think it's rather pointless to do bitwise operations on python > enums. We're not that close to the machine.
It makes sense if the enums represent bit-oriented values that will be used close to the machine. Python is used in many disciplines. Then it's up to the library writer to not use enums in that case. (assuming the performance of bitwise operations is critical here, which I doubt)
This is the point I was trying to make: once you use IntEnum (as you would in any case where you need bitwise operators), Enum gets out of the way for everything other than str, repr, and one other slot (that escapes me for the moment...).
The metaclass does extra work at definition time so there shouldn't be any runtime overhead - the slots should be inherited directly from the non-Enum parent.
Cheers, Nick.
-- Nick Coghlan | ncoghlan at gmail.com | Brisbane, Australia
- Previous message: [Python-Dev] Purpose of Doctests [Was: Best practices for Enum]
- Next message: [Python-Dev] Purpose of Doctests [Was: Best practices for Enum]
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]