Skip to content

Instantly share code, notes, and snippets.

@smallevilbeast
Created December 18, 2013 07:37
Show Gist options
  • Save smallevilbeast/8018653 to your computer and use it in GitHub Desktop.
Save smallevilbeast/8018653 to your computer and use it in GitHub Desktop.
pyqt test
import os
import sys
from PyQt4.QtCore import *
def quit():
print "Memory: ", int(os.popen('ps -p %d -o rss | tail -1' % os.getpid()).read())
sys.exit()
class Test(QObject):
@pyqtSlot()
def slot(self):
print "SLOT"
def init(self, l):
for x in xrange(100000):
o = QObject()
if signals:
if sigtype == 'func':
o.connect( o, SIGNAL('destroyed(QObject*)'), self.slot )
o.disconnect( o, SIGNAL('destroyed(QObject*)'), self.slot )
else:
o.connect( o, SIGNAL('destroyed(QObject*)'), self, SLOT('slot()') )
o.disconnect( o, SIGNAL('destroyed(QObject*)'), self, SLOT('slot()') )
l.append( o )
if len(sys.argv) <= 3:
print "Syntax: test.py one|two|two+remove|three+remove yes|no func|deco"
quit()
type=sys.argv[1]
signals=sys.argv[2]
sigtype=sys.argv[3]
if signals == 'yes':
signals = True
print "Executing '%s' with signals" % type
else:
signals = False
print "Executing '%s' without signals" % type
if type == 'one':
t = Test()
l1 = []
t.init(l1)
quit()
if type == 'two':
t = Test()
l1 = []
t.init(l1)
l2 = []
t.init(l2)
quit()
if type == 'two+remove':
t = Test()
l1 = []
t.init(l1)
l1 = [] # The first list is removed before executing again
l2 = []
t.init(l2)
quit()
if type == 'three+remove':
t = Test()
l1 = []
t.init(l1)
l1 = [] # The first list is removed before executing again
l2 = []
t.init(l2)
l2 = [] # The first list is removed before executing again
l3 = []
t.init(l3)
quit()
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment