On Sunday, May 22, 2011 03:42 AM, Roman Yakovenko wrote:
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.
Thank you for finding bug and providing a fix!
Any chance to get it applied?
As in many cases, the answer is "yes" and "no".
"Yes" - please open a ticket on sourceforge. I have few interesting
plans for version 2.0 which will introduce few breaking changes. I'll be
glad to insert your patch too
Done.
"No" - this is a "silent" breaking change. The developer may not pay
attention, that the last file was not updated by the code generator and
still to compile it. So, in this specific case, I prefer to keep the
whole process backward compatible and introduce the patch.
Hope, you understand.
I understand importance of backward compatibility and your desire to not
break compatibility is commendable. That being said I think it is still
worth considering fixing it. From my point of view the main point of
balanced file writer is to guarantee stable set of output files, so that
when one decides to expose one more class he wouldn't have to modify his
build system scripts/project files. This bug makes this use case nearly
impossible, as for instance in example above, if I expose one more class
I'll get 12 output files, as I keep adding classes it will grow to 14
output files when number of exposed classes reaches 28, and then will
drop back to 10 when number of classes becomes 30.
This is not exactly 'silent' breaking change either, as by default Py++
would delete extra output files and therefore build would fail.
If you don't buy these arguments, that's fine, it is your call. Would
you be interested in a backward compatible change? For instance have an
extra input to module_builder.write_balanced_files which would trigger
new splitting logic? If you don't want to clutter interface with extra
flags than could you suggest if there is a way to use my own
file_writer? I don't see easy way as module_builder.write_balanced_files
calls some private methods like __merge_user_code.
Cheers,
Kirill
_______________________________________________
Cplusplus-sig mailing list
Cplusplus-sig@python.org
http://mail.python.org/mailman/listinfo/cplusplus-sig