[issue35559] Optimize base64.b16decode to use compiled regex

2018-12-26 Thread Karthikeyan Singaravelan
Karthikeyan Singaravelan added the comment: Thanks for the feedback. I am closing this as rejected since it's not worth the cost of increasing import time and for performance reasons there are other options as Serhiy noted in msg332339. -- resolution: -> rejected stage: patch review

[issue35559] Optimize base64.b16decode to use compiled regex

2018-12-26 Thread Stefan Behnel
Stefan Behnel added the comment: I agree with Antoine. After all, we are optimising a safety check here that runs in linear time. If people want speed, they should consider methods that do not do this check in the first place. -- ___ Python tracke

[issue35559] Optimize base64.b16decode to use compiled regex

2018-12-22 Thread Antoine Pitrou
Antoine Pitrou added the comment: I don't think performance of base16 encoding is important enough to increase import times. I would recommend rejection. -- ___ Python tracker _

[issue35559] Optimize base64.b16decode to use compiled regex

2018-12-22 Thread Cheryl Sabella
Change by Cheryl Sabella : -- pull_requests: +10517 ___ Python tracker ___ ___ Python-bugs-list mailing list Unsubscribe: https://m

[issue35559] Optimize base64.b16decode to use compiled regex

2018-12-22 Thread Cheryl Sabella
Change by Cheryl Sabella : -- keywords: +patch pull_requests: +10516 stage: -> patch review ___ Python tracker ___ ___ Python-bugs-

[issue35559] Optimize base64.b16decode to use compiled regex

2018-12-22 Thread Cheryl Sabella
Change by Cheryl Sabella : -- pull_requests: -10516 ___ Python tracker ___ ___ Python-bugs-list mailing list Unsubscribe: https://

[issue35559] Optimize base64.b16decode to use compiled regex

2018-12-22 Thread Karthikeyan Singaravelan
Karthikeyan Singaravelan added the comment: Thanks Serhiy, the other issue noted about performance improvement removing casefold and I thought re.search per call to be inefficient. My bad that I didn't consider the cost of moving the compilation to module level that affects import time and a

[issue35559] Optimize base64.b16decode to use compiled regex

2018-12-22 Thread Serhiy Storchaka
Serhiy Storchaka added the comment: According to your results, you will save 0.94 us per call of b16decode, but loss 126 us at import time. You will get a benefit if b16decode is used more than 130 time. Currently, if the performance is critical, the user can use binascii.unhexlify() direct

[issue35559] Optimize base64.b16decode to use compiled regex

2018-12-22 Thread Karthikeyan Singaravelan
Karthikeyan Singaravelan added the comment: > How this affects the import time (use -X importtime)? Is there reliable way to benchmark this? On multiple runs with regex for python3 -X importtime -c 'import base64' import time: 677 | 11151 | base64 On multiple runs without regex f

[issue35559] Optimize base64.b16decode to use compiled regex

2018-12-22 Thread Karthikeyan Singaravelan
Karthikeyan Singaravelan added the comment: Thanks @scoder . I took the convention since most of the places I have seen capitalized variable ending with PAT but this looks more readable to me. I have made the changes in my PR. -- ___ Python tracke

[issue35559] Optimize base64.b16decode to use compiled regex

2018-12-21 Thread Serhiy Storchaka
Serhiy Storchaka added the comment: How this affects the import time (use -X importtime)? -- ___ Python tracker ___ ___ Python-bugs

[issue35559] Optimize base64.b16decode to use compiled regex

2018-12-21 Thread Stefan Behnel
Stefan Behnel added the comment: One regex related code pattern that I generally like is to assign bound methods to good names and use those. In this case, I would write _has_non_base16_digits = re.compile(b'[^0-9A-F]').search ... if _has_non_base16_digits(s): raise ... -- nosy:

[issue35559] Optimize base64.b16decode to use compiled regex

2018-12-21 Thread Karthikeyan Singaravelan
New submission from Karthikeyan Singaravelan : I came across this as a result of issue35557 and thought to make a new issue to keep the discussion separate. Currently the b16decode function uses a regex with re.search that can be compiled at the module level as a static variable to give up to