hgrecco/pint — pull request #167 by jbmohler (2014-07-03 14:56:39+00:00)
Title: Recurse cls method

See https://github.com/hgrecco/pint/pull/166 for rationale; this is a version of that with only the essential optimization respun as methods on `UnitRegistry`. The timings in the prior PR are accurate for this as well; it turns out I can't really justify some of the extras in that PR, but I may send them again later if I can pull out good cases for why they make sense.

If you prefer you could use https://github.com/jbmohler/pint/tree/recurse_nested with the nested function recursion. These are essentially indistinguishable in terms of speed and it varies both ways depending on recursion depth (I think). Even in this PR, the functions remain tightly coupled with the main public functions due to the accumulator variable; I personally like how the nested function makes that coupling very clear.