Created
February 5, 2023 07:01
-
-
Save nrbnlulu/7deeced080cd563c0749880f59e3ab1a to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
from functools import partial | |
from timeit import timeit | |
from PySide6.QtCore import QCoreApplication, QObject, Slot | |
from qtgql import slot | |
def manual(): | |
class ManualTyping(QObject): | |
@Slot(str, int, result="int") | |
def foo(self, a: str, b: int) -> int: | |
... | |
return ManualTyping | |
def auto(): | |
class FromTypeHints(QObject): | |
@slot | |
def foo(self, a: str, b: int) -> int: | |
... | |
return FromTypeHints | |
if __name__ == "__main__": | |
app = QCoreApplication() | |
print(f"Manual - class creation time -> {timeit(manual, number=10000)}") | |
print(f"Auto - class creation time -> {timeit(auto, number=10000)}") | |
manual_typing = manual() | |
a = manual_typing() | |
part = partial(a.foo, "", 2) | |
print(f"call slot time for {manual_typing} -> {timeit(part, number=100000)}") | |
from_annotations = auto() | |
a = manual_typing() | |
part = partial(a.foo, "", 2) | |
print(f"call slot time for {from_annotations} -> {timeit(part, number=100000)}") | |
app.exec() |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
where qtgql is would be https://github.com/nrbnlulu/qtgql