New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Fix AASTexData py2.6 incompatibility/performance boost #4641
Conversation
this will probably give a slight performance boost and also restores py2.6 compatibility (inportant because this line was originally added in a patch for v1.0.x)
👍 I'm fine with putting this in master! |
Looks OK. My normal style would be to call it something like |
Actually should just be |
Hmm... I didn't realize that about the caching, @taldcroft - good to know! One caveat though: https://docs.python.org/3.5/library/re.html#re.compile says this:
Doesn't that mean we should do this because astropy certainly uses a lot of different patterns in different places? I guess "most recent" is fairly ambiguous, though... |
Actually I answered my own question by looking at |
OK, change made. This muddies the water a bit in terms of whether it's worth having this in master... But my inclination is to just merge this and backport it for now as it probably now is basically neutral in terms of performance. If we want to remove it in another PR down the road, that's probably fine, as we just need to not backport it to 1.1.x or 1.0.x. |
@eteq - I'm fine with this going in master. |
Alright, I'll merge this now and backport, and that should restore py2.6 compatibility for the 1.0.x and 1.1.x branches. |
Fix AASTexData py2.6 incompatibility/performance boost
Fix AASTexData py2.6 incompatibility/performance boost
Fix AASTexData py2.6 incompatibility/performance boost
This is a slight adjustment to the change introduced in #4561 . It just pre-compiles the regex into an object that is then re-used in the
re.sub
call. While this is probably a trivial improvement on it's own, it has a much more important effect when backported to v1.1.x and v1.0.x: it fixes a py2.6 incompatibility introcued in #4561. It turns out that theflags
keyword is not inre.sub
in py2.6. So this PR works around that by using the compiled regex instead of compiling it as part of there.sub
call.In principal this could be put only in v1.0.x/v1.1.x... But I think it's better to put it in master, as it has no downside and might be a performance improvement. Any opinions on that, @astrofrog or @taldcroft ?
(note that no changelog entry is needed because #4561 has not been in a release yet)