Suppose you have 24 class_creators and trying to split them into 10 buckets. What it currently does is:
- how many creators per bucket? 24/10 = 2. uhm, ok.
- split_sequence of 24 creators by 2, this returns 12 buckets
- is actual number of buckets greater than requested? yes 12>10. Ok lets peel of last bucket and merge it into one before last.
Now we've got 11 buckets, and we happily write 11 files... but user asked for 10.
Here is a patch to fix it, it simply distributes class creators over buckets in round robin.
Any chance to get it applied?
--- balanced_files.py.orig 2011-05-19 15:58:24.000000000 +0800
+++ balanced_files.py 2011-05-19 16:44:12.000000000 +0800
@@ -13,7 +13,6 @@
from pygccxml import declarations
from pyplusplus import decl_wrappers
from pyplusplus import code_creators
-from pyplusplus.utils import split_sequence
#TODO: to add namespace_alias_t classes
@@ -52,10 +51,11 @@
class_creators = filter( lambda cc: not cc.declaration.already_exposed
, class_creators )
- buckets = split_sequence(class_creators, len(class_creators)/self.number_of_buckets )
- if len(buckets) > self.number_of_buckets:
- buckets[len(buckets)-2] += buckets[len(buckets)-1]
- buckets = buckets[:len(buckets)-1]
+ buckets = [] * self.number_of_buckets
+ i = 0
+ for c in class_creators:
+ buckets[i].append( c )
+ i = (i+1) % self.number_of_buckets
for index, bucket in enumerate( buckets ):