New submission from Gregory P. Smith <g...@krypto.org>:

Creating an enum subclass (ie: defining an enum) is slow.  This dramatically 
impacts startup time of Python programs that import a bunch of potentially 
needed constant definitions at startup before any proper code executes.

How slow?  So slow that a module defining a ~300 enums takes nearly 100ms just 
to import from its pyc file.

Example code: 
https://github.com/googleads/google-ads-python/blob/96fd08bb62435f1930df4871033ba8689333b67f/google/ads/google_ads/v2/services/enums.py

We've known this, we should do something about it.  (Even if it means 
implementing the guts of the magic enum machinery in C.)  ie, it came up in 
https://bugs.python.org/issue28637 as a stdlib startup time regression and is 
likely to come up in similar contexts elsewhere.

----------
components: Library (Lib)
messages: 355777
nosy: gregory.p.smith
priority: normal
severity: normal
stage: needs patch
status: open
title: enum classes cause slow startup time
type: performance
versions: Python 3.9

_______________________________________
Python tracker <rep...@bugs.python.org>
<https://bugs.python.org/issue38659>
_______________________________________
_______________________________________________
Python-bugs-list mailing list
Unsubscribe: 
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com

Reply via email to