Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • Users
  • Groups
  • Search
  • Get Qt Extensions
  • Unsolved
Collapse
Brand Logo
  1. Home
  2. Qt Development
  3. Qt for Python
  4. PySide2 seems a bit slow
Forum Updated to NodeBB v4.3 + New Features

PySide2 seems a bit slow

Scheduled Pinned Locked Moved Unsolved Qt for Python
pyside2qt for python
1 Posts 1 Posters 732 Views
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • M Offline
    M Offline
    METLAB
    wrote on last edited by
    #1

    I try to migrate from PyQt5 to PySide2 and I see PySide2 bit slower than PyQt5 on multithreading context switching.

    I've wrtitten a small programm and I see PySide2 up to 4 times slower

    #!/usr/bin/python3
    # -*- coding: utf-8 -*-
    
    import sys
    from PySide2.QtWidgets import QMainWindow, QPushButton, QApplication
    from PySide2.QtCore import QThread, Signal
    
    
    import datetime
    import time
    
    class Proc(QThread):
        
        procEvent    = Signal()
        
        def __init__(self, parent=None):
            QThread.__init__(self, parent=None)
            
            self.__flag = False
            
        def wakeup(self):
            self.__flag = False
            
        def __suspend(self):
            self.__flag = True
            while self.__flag:
                pass
        
        def isSuspended(self):
            return self.__flag
    
        def run(self):
            a = datetime.datetime.now()
            self.procEvent.emit()
            self.__suspend()
            b = datetime.datetime.now()
            print(b-a)
    
    class Example(QMainWindow):
    
        def __init__(self):
            super().__init__()
    
            self.initUI()
    
    
        def initUI(self):
            
            self.flag = True
    
            btn1 = QPushButton("Button 1", self)
            btn1.move(30, 50)
            
            self.procThread = Proc()
            self.procThread.procEvent.connect(self.procSlot)
           
            btn1.clicked.connect(self.buttonClicked)
            
    
            self.statusBar()
    
            self.setGeometry(300, 300, 290, 150)
            self.setWindowTitle('Event sender')
            self.show()
        
        
        def procSlot(self):
            self.waitProcThreadSleep()
            self.procThread.wakeup()
        
        def waitProcThreadSleep(self):
            while not self.procThread.isSuspended():
                pass
        
        def buttonClicked(self):
            self.procThread.start()
    
    
            
            
    if __name__ == '__main__':
    
        app = QApplication(sys.argv)
        ex = Example()
        sys.exit(app.exec_())
        
        
    # import sys
    # from PyQt5.QtWidgets import QMainWindow, QPushButton, QApplication
    # from PyQt5.QtCore import QThread, pyqtSignal
    # 
    # 
    # import datetime
    # import time
    # 
    # class Proc(QThread):
    #     
    #     procEvent    = pyqtSignal()
    #     
    #     def __init__(self, parent=None):
    #         QThread.__init__(self, parent=None)
    #         
    #         self.__flag = False
    #         
    #     def wakeup(self):
    #         self.__flag = False
    #         
    #     def __suspend(self):
    #         self.__flag = True
    #         while self.__flag:
    #             pass
    #     
    #     def isSuspended(self):
    #         return self.__flag
    # 
    #     def run(self):
    #         a = datetime.datetime.now()
    #         self.procEvent.emit()
    #         self.__suspend()
    #         b = datetime.datetime.now()
    #         print(b-a)
    # 
    # class Example(QMainWindow):
    # 
    #     def __init__(self):
    #         super().__init__()
    # 
    #         self.initUI()
    # 
    # 
    #     def initUI(self):
    #         
    #         self.flag = True
    # 
    #         btn1 = QPushButton("Button 1", self)
    #         btn1.move(30, 50)
    #         
    #         self.procThread = Proc()
    #         self.procThread.procEvent.connect(self.procSlot)
    #        
    #         btn1.clicked.connect(self.buttonClicked)
    #         
    # 
    #         self.statusBar()
    # 
    #         self.setGeometry(300, 300, 290, 150)
    #         self.setWindowTitle('Event sender')
    #         self.show()
    #     
    #     
    #     def procSlot(self):
    #         self.waitProcThreadSleep()
    #         self.procThread.wakeup()
    #     
    #     def waitProcThreadSleep(self):
    #         while not self.procThread.isSuspended():
    #             pass
    #     
    #     def buttonClicked(self):
    #         self.procThread.start()
    # 
    # 
    #         
    #         
    # if __name__ == '__main__':
    # 
    #     app = QApplication(sys.argv)
    #     ex = Example()
    #     sys.exit(app.exec_())
    
    1 Reply Last reply
    0

    • Login

    • Login or register to search.
    • First post
      Last post
    0
    • Categories
    • Recent
    • Tags
    • Popular
    • Users
    • Groups
    • Search
    • Get Qt Extensions
    • Unsolved