8000 bpo-39068 guard _b85chars2 initialization by drmonkeysee · Pull Request #17627 · python/cpython · GitHub
[go: up one dir, main page]

Skip to content

bpo-39068 guard _b85chars2 initialization #17627

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

Merged
merged 4 commits into from
Dec 31, 2020
Merged
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Next Next commit
guard _b85chars2 table
  • Loading branch information
drmonkeysee committed Dec 16, 2019
commit 04967d1d05f2a695ff7caded296791ae3f9a8f4c
1 change: 1 addition & 0 deletions Lib/base64.py
< 8000 table class=" diff-table js-diff-table tab-size " data-tab-size="8" data-diff-anchor="diff-1d196d93fbeed5133b0bc9de7b58a2f5a0caee15e693ba605c7182d127e7f263" data-paste-markdown-skip> Original file line number Diff line number Diff line change Expand Up @@ -430,6 +430,7 @@ def b85encode(b, pad=False): # if the function is never called if _b85chars is None:
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It is enough to check if _b85chars2 is None here.

These checks are cheap, but they are performed at every b85encode() call. Lesser checks is better.

a85encode() should be updated too. And may be other functions if they initialize two or more globals.

Copy link
Contributor Author
@drmonkeysee drmonkeysee Dec 16, 2019

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

done. visually scanned the file for other cases but only found the additional one in a85encode().

_b85chars = [bytes((i,)) for i in _b85alphabet] if _b85chars2 is None: _b85chars2 = [(a + b) for a in _b85chars for b in _b85chars] return _85encode(b, _b85chars, _b85chars2, pad)
Expand Down
0