[Python-ideas] Change magic strings to enums
Ethan Furman
ethan at stoneleaf.us
Wed Apr 25 12:20:51 EDT 2018
On 04/25/2018 03:15 AM, Ivan Levkivskyi wrote:
> On 25 April 2018 at 11:03, Serhiy Storchaka wrote:
>> Creating a new function is very cheap -- just around 50 ns on my computer.
>>
>> Creating a new class is over two orders costly -- around 7 us for an empty class on my computer.
>>
>> Creating a new Enum class is much more costly -- around 40 us for an empty class (or 50 us for IntEnum) plus 7 us
>> per member.
>
> Hm, this is what I wanted to know. I think by rewriting EnumMeta in C we can reduce the creation time of an Enum class
> (almost) down to the creation time of a normal class, which may be a 4-5x speed-up. What do you think?
Someone else would have to take that on (a C version of EnumMeta) -- my C skills are not up to that task and I do not
currently possess the time to get them there.
--
~Ethan~
More information about the Python-ideas
mailing list