Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

PR: Import all classes in QtTest module. #290

Merged
merged 1 commit into from
Dec 1, 2021

Conversation

kumattau
Copy link
Contributor

I made this PR to fix #197.

I use promote_enums in QtTest.
In Current QtPy, promote_enums is used in QtCore/QtGui/QtWidgets only, but is there any reason?

Copy link
Member

@dalthviz dalthviz left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks @kumattau for working on this! Could you do some benchmarking to know how much the addition of promote_enums affects the import time of the module? You can use something like timeit as done here: #271 (comment)

Otherwise this LGTM 👍 and thanks again for all the work!

@kumattau
Copy link
Contributor Author

kumattau commented Nov 30, 2021

I rebased onto master

@kumattau
Copy link
Contributor Author

@dalthviz ,

Thanks @kumattau for working on this! Could you do some benchmarking to know how much the addition of promote_enums affects the import time of the module? You can use something like timeit as done here: #271 (comment)

I measured the statement "from qtpy import QtTest" with QT_API=pyqt6.
The result is as follows. promote_enums in QtTest seems not to affect the import performance.

  • PyQt6 Version
PyQt6                      6.2.0
PyQt6-Qt6                  6.2.0
PyQt6-sip                  13.1.0
  • Measuring Script
    git log --oneline -n 1

    export QT_API=pyqt6
    statement="from qtpy import QtTest"

    python -m timeit -n 1 -r 1 "$statement"
    python -X importtime -c "$statement"
  • This PR
+ git log --oneline -n 1
dc9fd14 Import all classes in QtTest module.
+ export QT_API=pyqt6
+ QT_API=pyqt6
+ statement='from qtpy import QtTest'
+ python -m timeit -n 1 -r 1 'from qtpy import QtTest'
1 loop, best of 1: 20.8 msec per loop
+ python -X importtime -c 'from qtpy import QtTest'
import time: self [us] | cumulative | imported package
import time:       154 |        154 |   _io
import time:        88 |         88 |   marshal
import time:       353 |        353 |   posix
import time:       629 |       1223 | _frozen_importlib_external
import time:        86 |         86 |   time
import time:       317 |        403 | zipimport
import time:        40 |         40 |     _codecs
import time:       402 |        442 |   codecs
import time:       488 |        488 |   encodings.aliases
import time:       844 |       1772 | encodings
import time:       228 |        228 | encodings.utf_8
import time:       154 |        154 | _signal
import time:       227 |        227 | encodings.latin_1
import time:        30 |         30 |     _abc
import time:       241 |        271 |   abc
import time:       336 |        606 | io
import time:       238 |        238 |       types
import time:       692 |        930 |     enum
import time:        50 |         50 |       _sre
import time:       346 |        346 |         sre_constants
import time:       391 |        737 |       sre_parse
import time:       329 |       1115 |     sre_compile
import time:       728 |        728 |         _collections_abc
import time:        54 |         54 |           _operator
import time:       212 |        265 |         operator
import time:       109 |        109 |         keyword
import time:        35 |         35 |           _heapq
import time:       222 |        257 |         heapq
import time:       134 |        134 |         itertools
import time:       718 |        718 |         reprlib
import time:        49 |         49 |         _collections
import time:       751 |       3008 |       collections
import time:        35 |         35 |       _functools
import time:       597 |       3639 |     functools
import time:        55 |         55 |     _locale
import time:       135 |        135 |     copyreg
import time:       391 |       6263 |   re
import time:       304 |       6566 | warnings
import time:        45 |         45 |       _stat
import time:       143 |        187 |     stat
import time:       118 |        118 |       genericpath
import time:       163 |        281 |     posixpath
import time:       400 |        867 |   os
import time:       147 |        147 |   _sitebuiltins
import time:       149 |        149 |   _bootlocale
import time:       186 |        186 |     importlib
import time:       188 |        188 |       importlib.machinery
import time:       452 |        639 |     importlib.abc
import time:       432 |        432 |     contextlib
import time:       385 |       1640 |   importlib.util
import time:       173 |        173 |   sitecustomize
import time:       160 |        160 |   usercustomize
import time:      2119 |       5253 | site
import time:       244 |        244 |       packaging.__about__
import time:       143 |        387 |     packaging
import time:       244 |        244 |       collections.abc
import time:      1313 |       1557 |     typing
import time:       132 |        132 |     packaging._structures
import time:      3316 |       5391 |   packaging.version
import time:      1593 |       1593 |   platform
import time:       171 |        171 |           _weakrefset
import time:       341 |        511 |         weakref
import time:       281 |        791 |       pkgutil
import time:       294 |       1085 |     PyQt6
import time:        37 |         37 |       atexit
import time:       157 |        194 |     PyQt6.sip
import time:      4677 |       5954 |   PyQt6.QtCore
import time:        37 |         37 |     PyQt6.QtDataVisualization
import time:       335 |        371 |   qtpy.QtDataVisualization
import time:       196 |      13503 | qtpy
import time:      3552 |       3552 |     PyQt6.QtGui
import time:      4014 |       4014 |     PyQt6.QtWidgets
import time:      3203 |      10767 |   PyQt6.QtTest
import time:        96 |         96 |     qtpy.sip
import time:       142 |        238 |   qtpy.enums_compat
import time:       478 |      11482 | qtpy.QtTest
  • master
+ git log --oneline -n 1
3e05d12 Merge pull request #291 from kumattau/qttexttospeech
+ export QT_API=pyqt6
+ QT_API=pyqt6
+ statement='from qtpy import QtTest'
+ python -m timeit -n 1 -r 1 'from qtpy import QtTest'
1 loop, best of 1: 21.1 msec per loop
+ python -X importtime -c 'from qtpy import QtTest'
import time: self [us] | cumulative | imported package
import time:       245 |        245 |   _io
import time:        72 |         72 |   marshal
import time:       278 |        278 |   posix
import time:       598 |       1192 | _frozen_importlib_external
import time:        78 |         78 |   time
import time:       316 |        393 | zipimport
import time:        40 |         40 |     _codecs
import time:       406 |        445 |   codecs
import time:       559 |        559 |   encodings.aliases
import time:       806 |       1809 | encodings
import time:       276 |        276 | encodings.utf_8
import time:       193 |        193 | _signal
import time:       290 |        290 | encodings.latin_1
import time:        32 |         32 |     _abc
import time:       193 |        224 |   abc
import time:       201 |        425 | io
import time:       246 |        246 |       types
import time:       804 |       1050 |     enum
import time:        86 |         86 |       _sre
import time:       287 |        287 |         sre_constants
import time:       505 |        791 |       sre_parse
import time:       493 |       1370 |     sre_compile
import time:       712 |        712 |         _collections_abc
import time:        55 |         55 |           _operator
import time:       217 |        272 |         operator
import time:       109 |        109 |         keyword
import time:        36 |         36 |           _heapq
import time:       139 |        174 |         heapq
import time:        72 |         72 |         itertools
import time:       566 |        566 |         reprlib
import time:        49 |         49 |         _collections
import time:       639 |       2590 |       collections
import time:        36 |         36 |       _functools
import time:       519 |       3144 |     functools
import time:        56 |         56 |     _locale
import time:       137 |        137 |     copyreg
import time:       427 |       6182 |   re
import time:       315 |       6497 | warnings
import time:        44 |         44 |       _stat
import time:       143 |        187 |     stat
import time:       120 |        120 |       genericpath
import time:       158 |        278 |     posixpath
import time:       407 |        870 |   os
import time:       149 |        149 |   _sitebuiltins
import time:       235 |        235 |   _bootlocale
import time:       146 |        146 |     importlib
import time:       118 |        118 |       importlib.machinery
import time:       434 |        552 |     importlib.abc
import time:       393 |        393 |     contextlib
import time:       385 |       1474 |   importlib.util
import time:       184 |        184 |   sitecustomize
import time:        63 |         63 |   usercustomize
import time:      2518 |       5491 | site
import time:       261 |        261 |       packaging.__about__
import time:       152 |        412 |     packaging
import time:       251 |        251 |       collections.abc
import time:      1317 |       1568 |     typing
import time:       139 |        139 |     packaging._structures
import time:      3342 |       5460 |   packaging.version
import time:      1640 |       1640 |   platform
import time:       179 |        179 |           _weakrefset
import time:       355 |        533 |         weakref
import time:       297 |        830 |       pkgutil
import time:       309 |       1138 |     PyQt6
import time:        39 |         39 |       atexit
import time:       177 |        216 |     PyQt6.sip
import time:      5020 |       6373 |   PyQt6.QtCore
import time:        34 |         34 |     PyQt6.QtDataVisualization
import time:       189 |        223 |   qtpy.QtDataVisualization
import time:       207 |      13901 | qtpy
import time:      3663 |       3663 |     PyQt6.QtGui
import time:      4058 |       4058 |     PyQt6.QtWidgets
import time:      3510 |      11230 |   PyQt6.QtTest
import time:       107 |      11336 | qtpy.QtTest

Copy link
Member

@CAM-Gerlach CAM-Gerlach left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM, thanks @kumattau ! A little surprised to not see some kind of hit to the import lag, but as far as I can tell, your benchmark results look solid.

@kumattau
Copy link
Contributor Author

kumattau commented Dec 1, 2021

@CAM-Gerlach
Sorry, I accidentally requested a re-review.

Copy link
Member

@dalthviz dalthviz left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks @kumattau for working on this and the benchmarking! LGTM 👍

@dalthviz dalthviz merged commit c18c082 into spyder-ide:master Dec 1, 2021
@dalthviz
Copy link
Member

dalthviz commented Dec 1, 2021

I almost forgot to answer this @kumattau :

In Current QtPy, promote_enums is used in QtCore/QtGui/QtWidgets only, but is there any reason?

I would said it is because those are the most used modules and because to add the promote_enums to more modules we will need to make sure that the performance hit is acceptable (as we checked here). However, if you think there are more modules where the usage of promote enums is worthy let us know!

@kumattau kumattau deleted the qttest branch December 1, 2021 14:59
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

QtTest imports are incomplete
4 participants