<div dir="ltr">Xavion, <div>The better way to save memory is to use following techniques: <div><ol><li>don't import more than necessary; for example, import from PyQt5.QtCore, not from PyQt5.Qt<br></li><li>consider using Python slots (unrelated to Qt slots) for large numbers of objects stored in lists<br></li><li>consider delaying loading of data (from disk or network), and only load what the app can show/process/edit<br></li><li>use generators instead of lists by using range() and itertools module when possible, and consider creating your own generators using the yield statement<br></li><li>*might* save some mem by using struct module where appropriate<br></li><li>only create circular references when necessary (see <a href="http://engineering.hearsaysocial.com/2013/06/16/circular-references-in-python/">http://engineering.hearsaysocial.com/2013/06/16/circular-references-in-python/</a>), although it seems that python 3.4 is now quite good at deleting objects that were stuck in cyclical refs even if they have a del method (but the docs say that there can still be uncollectable garbage once in a while, without being specific, so if your app happens to generate a lot of objects with the particular kind of circular reference that is not collectable by interpreter, you would see steady increase in memory by your app as you create and delete those objects). Looks like objgraph might be a good utility for identifying cycles but I have not used it yet (just found out while researching this topic)<br></li></ol></div><div><br></div><div>All that being said, you should probably dig deeper into into all of the above only when you determine you have a memory leak or are using gigs more memory than necessary. </div><div>Oliver</div><div><br></div></div></div><div class="gmail_extra"><br clear="all"><div><div class="gmail_signature" data-smartmail="gmail_signature"><div dir="ltr"><div><div dir="ltr"><div dir="ltr"><div><font size="2" style="font-size:small">Oliver</font><div style="font-size:small"><font size="1">Open Source contributions: <a href="http://pubsub.sf.net/" style="color:rgb(17,85,204)" target="_blank">PyPubSub</a>,</font><span style="font-size:x-small"> </span><a href="https://github.com/schollii/nose2pytest" style="color:rgb(17,85,204);font-size:x-small" target="_blank">nose2pytest</a><span style="font-size:x-small">,</span><span style="font-size:x-small"> L</span><a href="http://lua-icxx.sf.net/" style="font-size:x-small;color:rgb(17,85,204)" target="_blank">ua-iCxx</a><span style="font-size:x-small">, </span><a href="http://iof.sf.net/" style="font-size:x-small;color:rgb(17,85,204)" target="_blank">iof</a></div><div style="font-size:small"><font size="1"><a href="http://stackoverflow.com/users/869951/schollii" style="color:rgb(17,85,204)" target="_blank">StackOverflow</a> contributions</font></div></div><div><font size="1"><br></font></div><div></div></div></div></div></div></div></div>
<br><div class="gmail_quote">On Tue, Sep 6, 2016 at 12:22 AM, Xavion <span dir="ltr"><<a href="mailto:xavion.0@gmail.com" target="_blank">xavion.0@gmail.com</a>></span> wrote:<br><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"><div dir="ltr">Hi All,<div><br></div><div>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.</div><div><br></div><div>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").</div><div><br></div><div>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.</div><span class="HOEnZb"><font color="#888888"><div><br clear="all"><div><br></div>-- <br><div><div dir="ltr"><span style="color:rgb(68,68,68)"><font size="2">Regards, Xavion.<br><br></font></span></div></div>
</div></font></span></div>
<br>______________________________<wbr>_________________<br>
PyQt mailing list    <a href="mailto:PyQt@riverbankcomputing.com">PyQt@riverbankcomputing.com</a><br>
<a href="https://www.riverbankcomputing.com/mailman/listinfo/pyqt" rel="noreferrer" target="_blank">https://www.<wbr>riverbankcomputing.com/<wbr>mailman/listinfo/pyqt</a><br></blockquote></div><br></div>