diff options
author | Christian Tismer <tismer@stackless.com> | 2022-05-26 17:47:54 +0200 |
---|---|---|
committer | Christian Tismer <tismer@stackless.com> | 2022-06-16 18:13:19 +0200 |
commit | 69293f068e98f428df7226fe622fdeff6dd6f891 (patch) | |
tree | dae2cfa9f73a109512bb9e8748c83d45b5f682db /sources/shiboken6/shibokenmodule/files.dir/shibokensupport/signature/loader.py | |
parent | 33ac539deb4c624c370aacf72b8a48e5ce1f7496 (diff) |
PyEnum: Use embedding of the Enum module for better execution speed
The Enum module was optimized several times and is now in good
shape. Old Python versions show massive slowdowns.
Also, Python 3.6 does not support the functional API.
As a general solution, we embed the current enum version to support older
Python versions with the same module. Newer Python versions do a normal import.
As a side effect, we have no longer to treat the old version
Python 3.6 in any special way.
This change is further necessary to be able to remove the old enum version,
since Python 3.6 still exists in CI.
NOTE: Python 3.6 and 3.7 had a hard-to-find refcount error
when creating new enums.
[ChangeLog][shiboken6] Python Enums use the newest implementation for
Python (3.10) for compatibility and speed.
Task-number: PYSIDE-1735
Change-Id: I1f105a6b0fb48e9364cb0654ccd9118d39f68542
Pick-to: 6.3
Reviewed-by: Christian Tismer <tismer@stackless.com>
Diffstat (limited to 'sources/shiboken6/shibokenmodule/files.dir/shibokensupport/signature/loader.py')
-rw-r--r-- | sources/shiboken6/shibokenmodule/files.dir/shibokensupport/signature/loader.py | 7 |
1 files changed, 7 insertions, 0 deletions
diff --git a/sources/shiboken6/shibokenmodule/files.dir/shibokensupport/signature/loader.py b/sources/shiboken6/shibokenmodule/files.dir/shibokensupport/signature/loader.py index b1c8ecf0a..aa2fa3adb 100644 --- a/sources/shiboken6/shibokenmodule/files.dir/shibokensupport/signature/loader.py +++ b/sources/shiboken6/shibokenmodule/files.dir/shibokensupport/signature/loader.py @@ -109,6 +109,13 @@ from shibokensupport.signature import importhandler from shibokensupport.signature.lib import enum_sig from shibokensupport.signature.lib import pyi_generator from shibokensupport.signature.lib import tool +if sys.version_info[:2] < (3, 10): + # PYSIDE-1735: Use the faster and more complete enum implementation. + from shibokensupport import enum_310 as enum + sys.modules["enum"] = enum + # compatibility + if sys.version_info[:2] < (3, 8): + enum.Enum._convert = classmethod(enum.EnumMeta._convert_) if "PySide6" in sys.modules: # We publish everything under "PySide6.support", again. |