pydata/pandas — pull request #1699 by taavi (2012-07-29 05:23:26+00:00)
Title: Avoid extra calls to calendar.monthrange.

daysinmonth isn't used beyond setting cal, which is only used if calendar_end or business_end. Putting the if check in improved performance by a factor of 10. Once all of the flags are false, they can never become true (because of the &= operations), and short-circuiting the rest of the loop in that case saved an additional 20% runtime in the provided example code (see #1686).

Much simpler than rewriting in Cython for now. monthrange is relatively expensive and was being called 3x per index datetime when doing a .resample("T"...) operation.

Thanks for the help from Erik Welch!