I guess this all works, but it seems that all you care about is if all jobids have one value.  Once you discover a jobid that is not the same as the others, can't you save cycles by exiting the loop?  You can add something after this line like:

                            jobids[jid] = 1
+                            if len(jobids) > 1:
+                                   break

Or you could enumerate the for loop and break if this assignement is not the first.