<div dir="ltr"><div class="gmail_extra"><div class="gmail_quote">On 25 April 2018 at 11:03, Serhiy Storchaka <span dir="ltr"><<a href="mailto:storchaka@gmail.com" target="_blank">storchaka@gmail.com</a>></span> wrote:<br><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">25.04.18 10:57, Ivan Levkivskyi пише:<span class=""><br>
<blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">
On 25 April 2018 at 06:03, INADA Naoki <<a href="mailto:songofacandy@gmail.com" target="_blank">songofacandy@gmail.com</a> <mailto:<a href="mailto:songofacandy@gmail.com" target="_blank">songofacandy@gmail.com</a><wbr>>> wrote:<br>
    enum class&member creation cost is much heavier than "import enum" cost.<br>
    Especially, "import socket, ssl" is much slower than before...<br>
<br>
Is it slow simply because we are creating new  class objects or EnumMeta.__new__ does<br>
some extensive calculations? In the latter case rewriting EnumMeta in C might help.<br>
</blockquote>
<br></span>
Creating a new function is very cheap -- just around 50 ns on my computer.<br>
<br>
Creating a new class is over two orders costly -- around 7 us for an empty class on my computer.<br>
<br>
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.<br><div class="HOEnZb"><div class="h5"><br></div></div></blockquote><div><br></div><div>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</div><div>(almost) down to the creation time of a normal class, which may be a 4-5x speed-up. What do you think?</div><div><br></div><div>--</div><div>Ivan </div></div><br></div><div class="gmail_extra"><br></div></div>