-
-
Notifications
You must be signed in to change notification settings - Fork 32.7k
GH-137224:Optimize base64.py performance #137223
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
Conversation
Most changes to Python require a NEWS entry. Add one using the blurb_it web app or the blurb command-line tool. If this change has little impact on Python users, wait for a maintainer to apply the |
This comment was marked as duplicate.
This comment was marked as duplicate.
This comment was marked as duplicate.
This comment was marked as duplicate.
Most changes to Python require a NEWS entry. Add one using the blurb_it web app or the blurb command-line tool. If this change has little impact on Python users, wait for a maintainer to apply the |
Most changes to Python require a NEWS entry. Add one using the blurb_it web app or the blurb command-line tool. If this change has little impact on Python users, wait for a maintainer to apply the |
Most changes to Python require a NEWS entry. Add one using the blurb_it web app or the blurb command-line tool. If this change has little impact on Python users, wait for a maintainer to apply the |
Most changes to Python require a NEWS entry. Add one using the blurb_it web app or the blurb command-line tool. If this change has little impact on Python users, wait for a maintainer to apply the |
Most changes to Python require a NEWS entry. Add one using the blurb_it web app or the blurb command-line tool. If this change has little impact on Python users, wait for a maintainer to apply the |
Most changes to Python require a NEWS entry. Add one using the blurb_it web app or the blurb command-line tool. If this change has little impact on Python users, wait for a maintainer to apply the |
Most changes to Python require a NEWS entry. Add one using the blurb_it web app or the blurb command-line tool. If this change has little impact on Python users, wait for a maintainer to apply the |
Most changes to Python require a NEWS entry. Add one using the blurb_it web app or the blurb command-line tool. If this change has little impact on Python users, wait for a maintainer to apply the |
Most changes to Python require a NEWS entry. Add one using the blurb_it web app or the blurb command-line tool. If this change has little impact on Python users, wait for a maintainer to apply the |
Most changes to Python require a NEWS entry. Add one using the blurb_it web app or the blurb command-line tool. If this change has little impact on Python users, wait for a maintainer to apply the |
Most changes to Python require a NEWS entry. Add one using the blurb_it web app or the blurb command-line tool. If this change has little impact on Python users, wait for a maintainer to apply the |
Hello, thanks for the contribution however this PR includes hundreds of cosmetic changes to the point where is is difficult to tell what is new. If you would like to implement this, please create an issue (look to other issues for inspiration as to how it should look), where you clearly list what/why/how, and provide benchmarks. Then you can resubmit a refined PR. |
@@ -10,41 +10,63 @@ | |||
|
|||
__all__ = [ | |||
# Legacy interface exports traditional RFC 2045 Base64 encodings | |||
'encode', 'decode', 'encodebytes', 'decodebytes', | |||
"encode", |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Multliple exports per line is normal in our code.
raise TypeError( | ||
"argument should be a bytes-like object or ASCII " | ||
"string, not %r" % s.__class__.__name__ | ||
) from None |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This was fine as it was.
def _bytes_from_decode_data(s): | ||
if isinstance(s, str): | ||
try: | ||
return s.encode('ascii') | ||
return s.encode("ascii") |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Single quotes are fine. Please read PEP 8.
b"z" | ||
if foldnuls and not word | ||
else b"y" |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This reformatting is not correct.
@@ -0,0 +1 @@ | |||
Instead, it now utilizes a frozenset named _ALLOWED_BASE16_CHARS for efficient character validation. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Better: "Use a frozenset, _ALLOWED_BASE16_CHARS, for efficient character validation."
Most of the style/format changes are incorrect or the original author's choice. Even those suggested by PEP 8 for new code are not required for existing code and are best done by or at the suggestion of a core developer in a separate PR that is part of a review of the module. Please carefully read the PEP before submitting another patch. Such a patch should only have changes needed for the enhancement. |
Instead, it now utilizes a frozenset named _ALLOWED_BASE16_CHARS for efficient character validation