[PyQt] Attempting to reduce the memory footprint of my PyQt5 application

David Boddie david at boddie.org.uk
Wed Sep 7 00:03:30 BST 2016


On Tue Sep 6 05:22:29 BST 2016, Xavion wrote:

> I'm trying to cut down on the memory usage of my PyQt5 application.  I'm
> assuming that one way to do this is to only import the Qt submodules that
> are actually used.
> 
> The three attached files illustrate my point.  The Qt5 Designer only
> imports the necessary submodules (e.g. "QtCore/QVariant").  Whereas, the
> PyQt5 UIC and RCC generators import the parent modules in full (e.g.
> "QtCore").

In PyQt, unless I'm mistaken, you get the whole module when you import a
class from it so there's no way to just import the classes you use. There
may be some tricks done to save memory at run-time but you will already be
benefiting from those.

> Assuming my memory reduction theory is right, is there any way that I can
> get the UIC and RCC generators to behave like the Qt5 Designer?  There's
> probably no point in using this strategy throughout the rest of my code if
> not.

I don't think there's a strategy to use.

You could check to see that you're not importing modules that you don't use.
Otherwise, I'm not sure if I can give you any general memory-saving tips.
Perhaps others can offer some advice here.

David


More information about the PyQt mailing list