Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Optimize Base64 decoding with ignored characters #144264

Open
Labels
3.15new features, bugs and security fixesextension-modulesC modules in the Modules dirperformancePerformance or resource usage
@serhiy-storchaka

Description

@serhiy-storchaka

Base64 decoding was optimized in#124951. But the optimization only worked to the first ignored character. The proposed PR makes it used even if there are some ignored characters (e.g. multiline data).

Examples:

$ ./python -m timeit -s 'import binascii; a = (b"a"*76+b"\n")*1000' 'binascii.a2b_base64(a)'baseline:  10000 loops, best of 5: 37.7 usec per loopoptimized: 10000 loops, best of 5: 20.2 usec per loop
$ ./python -m timeit -s 'import binascii; a = (b"a"*76+b"\n")*1000' 'binascii.a2b_base64(a, ignorechars=b" \t\n\r\v")'baseline:  5000 loops, best of 5: 42.7 usec per loopoptimized: 10000 loops, best of 5: 21.3 usec per loop

For comparison, Base64 decoding without ignored characters:

$ ./python -m timeit -s 'import binascii; a = (b"a"*76)*1000' 'binascii.a2b_base64(a)'20000 loops, best of 5: 17.3 usec per loop

Linked PRs

Metadata

Metadata

Assignees

No one assigned

    Labels

    3.15new features, bugs and security fixesextension-modulesC modules in the Modules dirperformancePerformance or resource usage

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions


      [8]ページ先頭

      ©2009-2026 Movatter.jp