Skip to content

Conversation

eloraburns
Copy link
Contributor

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!

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 pandas-dev#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!
@wesm
Copy link
Member

wesm commented Aug 12, 2012

thanks, just cherry-picked this commit

@wesm wesm closed this Aug 12, 2012
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants