4 ms·
Maybe you're the person to ask. My Python Qt app is sluggish when it loads tens of thousands of values from SQLite. Various variations of pagination and lazy lo
by dotancohen 2y ago
Maybe you're the person to ask. My Python Qt app is sluggish when it loads tens of thousands of values from SQLite. Various variations of pagination and lazy loading hurt usability. But isolating the issue and testing with C++ and Rust show that those two languages don't have the performance hit of Python.
I could use C++ and stick with Qt, but I'd much prefer Rust. Rust has no good Qt bindings. What are my options?
The app makes use of QV/HBoxLayout, QWidget, Qdialog, QPushButton, and other really standard features. It reads from the filesystem, reads and writes to SQLite, and outputs sound from mostly ogg files at various speeds (through VLC behind the scenes). I stick with Qt because I like how it integrates with KDE and other desktops flawlessly.
- jpc0 2y agohttps://areweguiyet.com/ https://areweguiyet.com/ Also did you test similar functionality in C++, I haven’t compared many implementations but I app I use that has an SQlite db being read with Qt(C++) is pretty sluggish whenever you touch the DB. Maybe store the values in a dict and only read/write from sqlite when needed. Dicts are very fast in python.
- dotancohen 2y agoYes, that's what I'm doing. It's the initial load that is heavy. I've also tried implementing lazy loading and pagination, with a pseudo-infinite scroll technique based on SQL LIMIT pagination, but the resulting CPU and memory spikes are noticeable.
- prmoustache 2y agoThis website is useless if accessibility compatibility is not mentionned.
- jenadine 2y ago> I could use C++ and stick with Qt, but I'd much prefer Rust. Rust has no good Qt bindings. What are my options? There are several Qt binding for rust, for example cxx-qt. I haven't tried myself but it looks maintained. Why is it not good? Otherwise, the most promising equivalent to Qt in Rust would be Slint.
- dotancohen 2y agoThanks. I forget why I discounted cxx-qt. It think it didn't support some common Q* object but I don't remember which. I'll experiment with it and with Slint, which I've been eyeballing anyway. Thank you.
- mixmastamyk 2y agoIs Cython and/or avoiding copies an option?
- dotancohen 2y agoCython is a great idea, thank you. I'll definitely try that. The code is all properly typed anyway. I'm not sure what you mean by avoiding copies. I'm rather stringent with memory, I don't have superfluous copies of data in memory. Or did you mean something else? Thank you.
- mixmastamyk 2y agoSometimes Python code makes copies when we’re not expecting it to. Hard to know but performance optimization books/blogs discuss it.
- dotancohen 2y agoI'll Google for that, thank you!
- rc00 2y ago> What are my options? > I stick with Qt These come up on search results if you combine Qt plus the language. Go: * https://github.com/mappu/miqt https://github.com/mappu/miqt Java: * https://github.com/OmixVisualization/qtjambi https://github.com/OmixVisualization/qtjambi Nim: * https://github.com/jerous86/nimqt https://github.com/jerous86/nimqt * https://github.com/seaqt/nim-seaqt https://github.com/seaqt/nim-seaqt Zig: * https://github.com/rcalixte/libqt6zig https://github.com/rcalixte/libqt6zig
- dotancohen 2y agoThank you. I don't see Java as having a performance edge over Python )) Same for the other languages - they likely won't have the performance of C++ or Rust. But I'll test them anyway, even just for the academic exercise the endeavour is worthwhile. Thank you.
- freedomben 2y agoJava is actually pretty fast, and certainly much, much faster than python. There are plenty of reasons Java isn't my preferred language, but speed is not one of them.
- dotancohen 2y agoThis is great to know, thank you. I still remember the days of the knock, knock jokes about Java.
- ido 2y agoThe jokes were mostly about startup time for the JVM (only happens once as when its in RAM it stays there and the loading time doesn't repeat for the next java program you run). It was also a lot more notable in the 90s when java was a browser plugin to run applets and browsers were single threaded (so the browser froze for a few seconds while the JVM loaded). I think it's been out of date for a long time with modern computers having much more RAM and speedy SSDs (and also JVM optimizations). For actual run time performance once its loaded the JVM has had great performance in the early 00s already and improved since. And for server side it was never an issue as you don't restart the server very often (so the JVM is always already loaded).