Details
Description
I have a data with 1000 records showing in QTableWidget (13 columns), after refresh 4 times, I get setItem 52000 times, and using pycharm Profile method, the time for 52000 times is 84ms. After PySide2 come out ( Qt for Python 5.11 mid May), I only change from "from PyQt5... import ..." to "from PySide2... import ..." for my program, the time for 52000 times is 3171ms. I know both PyQt5 and PySide2 depend on Qt5, but the performance shocked. I want to use PySide2 for future with LGPL, how can I fix it ?
// code placeholder #!/usr/bin/env python # -*- coding: utf-8 -*- import sys from PySide2.QtWidgets import QApplication, QTableWidgetItem, QMainWindow, QTableWidget class MainWindow(QMainWindow): def __init__(self): super().__init__() self.setGeometry(200, 300, 960, 540) self.table = QTableWidget() self.setCentralWidget(self.table) self.table.setRowCount(1000) self.horizontal_header = ["1", "2", "3", "4", "5", "6", "7", "8", "9", "10", "11", "12", "13"] self.table.setColumnCount(len(self.horizontal_header)) self.table.setHorizontalHeaderLabels(self.horizontal_header) for i in range(4): self._run() raise NameError def _run(self): for row in range(1000): for column in range(13): item = QTableWidgetItem('1') self.table.setItem(row, column, item) if __name__ == '__main__': app = QApplication(sys.argv) mainwindow = MainWindow() mainwindow.show() sys.exit(app.exec_())
Qt 5.11.1 (x86_64-little_endian-lp64 shared (dynamic) release build; by GCC 7.2.0) Attempt # 0 / 4 Populating 1000 Done 44 ms Attempt # 1 / 4 Populating 1000 Done 972 ms Attempt # 2 / 4 Populating 1000 Done 989 ms Attempt # 3 / 4 Populating 1000 Done 1056 ms
C++ "5.11.1 xcb" ()
Qt 5.11.1 (x86_64-little_endian-lp64 shared (dynamic) release build; by GCC 7.2.0)
Attempt # 0 / 4
Populating 1000
Done 5 ms
Attempt # 1 / 4
Populating 1000
Done 5 ms
Attempt # 2 / 4
Populating 1000
Done 5 ms
Attempt # 3 / 4
Populating 1000
Done 5 ms
Attachments
For Gerrit Dashboard: PYSIDE-727 | ||||||
---|---|---|---|---|---|---|
# | Subject | Branch | Project | Status | CR | V |
233921,5 | WIP: Change list to vector to look for converter | 5.11 | pyside/pyside-setup | Status: ABANDONED | -2 | 0 |
234768,5 | libshiboken: Refactor loops | dev | pyside/pyside-setup | Status: MERGED | +2 | 0 |
234769,1 | WIP: libshiboken: Change lists to vectors | 5.11 | pyside/pyside-setup | Status: DEFERRED | -2 | 0 |
234873,2 | libshiboken: Use std::set::find() instead of searching the set | 5.11 | pyside/pyside-setup | Status: MERGED | +2 | 0 |
235532,1 | libshiboken: Change lists to vectors | dev | pyside/pyside-setup | Status: ABANDONED | 0 | 0 |
235561,2 | libshiboken: Fix container types | dev | pyside/pyside-setup | Status: MERGED | +2 | 0 |
238429,2 | libshiboken: Use empty() to check for empty containers as clang-tidy advises | 5.11 | pyside/pyside-setup | Status: MERGED | +2 | 0 |