[issue38659] enum classes cause slow startup time
Gregory P. Smith
report at bugs.python.org
Thu Oct 31 21:12:48 EDT 2019
New submission from Gregory P. Smith <greg at 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 <report at bugs.python.org>
<https://bugs.python.org/issue38659>
_______________________________________
More information about the Python-bugs-list
mailing list