On Wed, Nov 23, 2011 at 4:49 PM, Terry Reedy <tjre...@udel.edu> wrote: > I personally strongly prefer the one-line formula to the hardcoded magic > numbers calculated from the formula. I find it much more readable. To me, > the only justification for the switch would be if there is a serious worry > about the kind being changed to something other than 1, 2, or 4. But the > fact that this is checked with an assert that can be optimized away negates > that. The one-liner could be followed by > assert(kind==1 || kind==2 || kind==4) > which would also serve to remind the reader of the possibilities. You could > even follow the formula with /* 4, 6, or 10 */ I think you reverted too > soon.
+1 to what Terry said here, although I would add a genuinely explanatory comment that gives the calculation meaning: /* For each character, allow for "\U" prefix and 2 hex digits per byte */ expandsize = 2 + 2 * kind; Cheers, Nick. -- Nick Coghlan | ncogh...@gmail.com | Brisbane, Australia _______________________________________________ Python-Dev mailing list Python-Dev@python.org http://mail.python.org/mailman/listinfo/python-dev Unsubscribe: http://mail.python.org/mailman/options/python-dev/archive%40mail-archive.com