aboutsummaryrefslogtreecommitdiffstats
path: root/sources/pyside2/tests
diff options
context:
space:
mode:
authorChristian Tismer <tismer@stackless.com>2020-07-25 00:58:18 +0200
committerChristian Tismer <tismer@stackless.com>2020-07-31 15:29:12 +0200
commitf2c973af4bd7cc1d87ec8ccfecadb7a475b723da (patch)
tree7b94124fe5400e56215e3b20c0fbb134a46a8825 /sources/pyside2/tests
parentedf28c5e97800b0c3442cd5351b6811ec85beead (diff)
feature-select: optimize feature access to the feasible maximum
** fix: MSVC needs extra sign bit in basewrapper_p.h! Buglet? ** The new feature selection has some tiny overhead. It is about two dict accesses plus a slot access for every tp_(get|set)attro call. The introduction of an explicit `__init_feature__` call allows to optimize this overhead very nicely, because this init is done for each __feature__ import: First, we can remove that tiny overhead completely by not initializing the feature_select module at all if no __feature__ import is used. Second, we can optimize this access further by caching the current module dict. If the dict is unchanged, then the last select_id can be used. This reduces the overhead of frequent calls to a single slot access. Third, we finally cache the select id in unused SbkObjectType bits. That removes the last structure where repeated attribute lookup is used. The overhead is therefore quite small when something is changed. But typically these changes are infrequent. The majority of accesses do change nothing, and this case is now quite much optimized. Change-Id: I7d1a4611a1c19216fd9be8f04457bb18ebd52ab1 Reviewed-by: Christian Tismer <tismer@stackless.com>
Diffstat (limited to 'sources/pyside2/tests')
-rw-r--r--sources/pyside2/tests/QtCore/multiple_feature_test.py9
1 files changed, 5 insertions, 4 deletions
diff --git a/sources/pyside2/tests/QtCore/multiple_feature_test.py b/sources/pyside2/tests/QtCore/multiple_feature_test.py
index 26488326c..351090382 100644
--- a/sources/pyside2/tests/QtCore/multiple_feature_test.py
+++ b/sources/pyside2/tests/QtCore/multiple_feature_test.py
@@ -48,7 +48,8 @@ from init_paths import init_test_paths
init_test_paths(False)
from PySide2 import QtCore
-from PySide2.support.__feature__ import _really_all_feature_names
+from PySide2.support.__feature__ import (
+ _really_all_feature_names, pyside_feature_dict)
from textwrap import dedent
"""
@@ -67,7 +68,6 @@ class FeaturesTest(unittest.TestCase):
"""
Test for all 256 possible combinations of `__feature__` imports.
"""
- global __name__
def tst_bit0(flag, self):
if flag == 0:
@@ -108,9 +108,10 @@ class FeaturesTest(unittest.TestCase):
tst_bit4, tst_bit5, tst_bit6, tst_bit7]
for idx in range(0x100):
- __name__ = "feature_{:02x}".format(idx)
+ pyside_feature_dict.clear()
+ config = "feature_{:02x}".format(idx)
print()
- print("--- Feature Test Module `{}` ---".format(__name__))
+ print("--- Feature Test Config `{}` ---".format(config))
print("Imports:")
for bit in range(8):
if idx & 1 << bit: