'Compute all differences between the current object set and the reference set.
Print a set of reports for created, deleted, and persistent objects'

def diff(self, **kargs):

    (refs, count, objs) = self.collect()
    delRefs = {}
    for i in list(self.startRefs.keys()):
        if (i not in refs):
            delRefs[i] = self.startRefs[i]
            del self.startRefs[i]
            self.forgetRef(delRefs[i])
    for i in list(self.newRefs.keys()):
        if (i not in refs):
            delRefs[i] = self.newRefs[i]
            del self.newRefs[i]
            self.forgetRef(delRefs[i])
    persistentRefs = {}
    createRefs = {}
    for o in refs:
        if (o not in self.startRefs):
            if (o not in self.newRefs):
                createRefs[o] = refs[o]
            else:
                persistentRefs[o] = refs[o]
    for r in self.newRefs:
        self.forgetRef(self.newRefs[r])
    self.newRefs.clear()
    self.newRefs.update(persistentRefs)
    self.newRefs.update(createRefs)
    for r in self.newRefs:
        self.rememberRef(self.newRefs[r])
    self.persistentRefs.clear()
    self.persistentRefs.update(persistentRefs)
    print('-----------    Count    changes    since    start:    ----------')
    c1 = count.copy()
    for k in self.startCount:
        c1[k] = (c1.get(k, 0) - self.startCount[k])
    typs = list(c1.keys())
    typs.sort(key=(lambda a: c1[a]))
    for t in typs:
        if (c1[t] == 0):
            continue
        num = ('%d' % c1[t])
        print(((('        ' + num) + ('    ' * (10 - len(num)))) + str(t)))
    print(('-----------        %d    Deleted    since    last    diff:    ------------' % len(delRefs)))
    self.report(delRefs, objs, **kargs)
    print(('-----------        %d    Created    since    last    diff:    ------------' % len(createRefs)))
    self.report(createRefs, objs, **kargs)
    print(('-----------        %d    Created    since    start    (persistent):    ------------' % len(persistentRefs)))
    self.report(persistentRefs, objs, **kargs)
