Skip to content

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

Closed
wants to merge 15 commits into from

Conversation

lighting9999
Copy link

@lighting9999 lighting9999 commented Jul 30, 2025

Instead, it now utilizes a frozenset named _ALLOWED_BASE16_CHARS for efficient character validation

@python-cla-bot
Copy link

python-cla-bot bot commented Jul 30, 2025

All commit authors signed the Contributor License Agreement.

CLA signed

@bedevere-app
Copy link

bedevere-app bot commented Jul 30, 2025

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 skip news label instead.

@bedevere-app

This comment was marked as duplicate.

@bedevere-app

This comment was marked as duplicate.

@lighting9999 lighting9999 changed the title Optimize base64.py performance GH-137223:Optimize base64.py performance Jul 30, 2025
@bedevere-app
Copy link

bedevere-app bot commented Jul 30, 2025

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 skip news label instead.

@lighting9999 lighting9999 changed the title GH-137223:Optimize base64.py performance GH-137224:Optimize base64.py performance Jul 30, 2025
@bedevere-app
Copy link

bedevere-app bot commented Jul 30, 2025

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 skip news label instead.

@bedevere-app
Copy link

bedevere-app bot commented Jul 30, 2025

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 skip news label instead.

@bedevere-app
Copy link

bedevere-app bot commented Jul 30, 2025

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 skip news label instead.

@bedevere-app
Copy link

bedevere-app bot commented Jul 30, 2025

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 skip news label instead.

@bedevere-app
Copy link

bedevere-app bot commented Jul 30, 2025

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 skip news label instead.

@bedevere-app
Copy link

bedevere-app bot commented Jul 30, 2025

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 skip news label instead.

@bedevere-app
Copy link

bedevere-app bot commented Jul 30, 2025

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 skip news label instead.

@bedevere-app
Copy link

bedevere-app bot commented Jul 30, 2025

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 skip news label instead.

@bedevere-app
Copy link

bedevere-app bot commented Jul 30, 2025

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 skip news label instead.

@bedevere-app
Copy link

bedevere-app bot commented Jul 30, 2025

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 skip news label instead.

@StanFromIreland
Copy link
Member

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.

@lighting9999 lighting9999 deleted the path-1 branch July 30, 2025 06:28
@@ -10,41 +10,63 @@

__all__ = [
# Legacy interface exports traditional RFC 2045 Base64 encodings
'encode', 'decode', 'encodebytes', 'decodebytes',
"encode",
Copy link
Member

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.

Comment on lines +61 to +64
raise TypeError(
"argument should be a bytes-like object or ASCII "
"string, not %r" % s.__class__.__name__
) from None
Copy link
Member

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")
Copy link
Member

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.

Comment on lines +351 to +353
b"z"
if foldnuls and not word
else b"y"
Copy link
Member

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.
Copy link
Member

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."

@terryjreedy
Copy link
Member

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.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants