##// END OF EJS Templates
worker: change partition strategy to every Nth element...
Gregory Szorc -
r28181:f8efc8a3 default
parent child Browse files
Show More
@@ -152,14 +152,11 if os.name != 'nt':
152 152 _exitstatus = _posixexitstatus
153 153
154 154 def partition(lst, nslices):
155 '''partition a list into N slices of equal size'''
156 n = len(lst)
157 chunk, slop = n / nslices, n % nslices
158 end = 0
159 for i in xrange(nslices):
160 start = end
161 end = start + chunk
162 if slop:
163 end += 1
164 slop -= 1
165 yield lst[start:end]
155 '''partition a list into N slices of roughly equal size
156
157 The current strategy takes every Nth element from the input. If
158 we ever write workers that need to preserve grouping in input
159 we should consider allowing callers to specify a partition strategy.
160 '''
161 for i in range(nslices):
162 yield lst[i::nslices]
General Comments 0
You need to be logged in to leave comments. Login now