[Python-ideas] Change magic strings to enums

Ivan Levkivskyi levkivskyi at gmail.com
Wed Apr 25 03:57:24 EDT 2018


On 25 April 2018 at 06:03, INADA Naoki <songofacandy at gmail.com> wrote:

> On Wed, Apr 25, 2018 at 12:04 PM, Nick Coghlan <ncoghlan at gmail.com> wrote:
> > On 25 April 2018 at 04:56, Ethan Furman <ethan at stoneleaf.us> wrote:
> >> On 04/24/2018 10:32 AM, Antoine Pitrou wrote:
> >>
> >>> Also beware the import time cost of having a widely-used module like
> >>> "warnings" depend on the "enum" module and its own dependencies.
> >>
> >>
> >> With all the recent changes to Python, I should go through and see which
> >> dependencies are no longer needed.
> >
> > I was checking this with "./python -X importtime -c 'import enum'",
> > and the overall import time was around 9 ms with a cold disk cache,
> > and 2 ms with a warm one. In both cases, importing "types" and
> > "_collections" accounted for around a 3rd of the time, with the bulk
> > of the execution time being enum's own module level code.
> >
>
> enum class&member creation cost is much heavier than "import enum" cost.
> Especially, "import socket, ssl" is much slower than before...
>
>
Is it slow simply because we are creating new  class objects or
EnumMeta.__new__ does
some extensive calculations? In the latter case rewriting EnumMeta in C
might help.

--
Ivan
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.python.org/pipermail/python-ideas/attachments/20180425/849001d1/attachment.html>


More information about the Python-ideas mailing list