mercurial/worker.py
changeset 18637 ac4dbceeb14a
parent 18636 dcb27c153a40
child 18638 047110c0e2a8
equal deleted inserted replaced
18636:dcb27c153a40 18637:ac4dbceeb14a
    50     outweigh the cost of starting them'''
    50     outweigh the cost of starting them'''
    51     linear = costperop * nops
    51     linear = costperop * nops
    52     workers = _numworkers(ui)
    52     workers = _numworkers(ui)
    53     benefit = linear - (_startupcost * workers + linear / workers)
    53     benefit = linear - (_startupcost * workers + linear / workers)
    54     return benefit >= 0.15
    54     return benefit >= 0.15
       
    55 
       
    56 def partition(lst, nslices):
       
    57     '''partition a list into N slices of equal size'''
       
    58     n = len(lst)
       
    59     chunk, slop = n / nslices, n % nslices
       
    60     end = 0
       
    61     for i in xrange(nslices):
       
    62         start = end
       
    63         end = start + chunk
       
    64         if slop:
       
    65             end += 1
       
    66             slop -= 1
       
    67         yield lst[start:end]