Skip to content

gh-128213: fast path for bytes creation from list and tuple - #128214

Open
blhsing wants to merge 7 commits into
python:mainfrom
blhsing:fast-bytes-creation-from-list-tuple
Open

gh-128213: fast path for bytes creation from list and tuple#128214
blhsing wants to merge 7 commits into
python:mainfrom
blhsing:fast-bytes-creation-from-list-tuple

Conversation

@blhsing

@blhsing blhsing commented Dec 24, 2024

Copy link
Copy Markdown
Contributor

Benchmark using python -m timeit -n 100 -s 'a = __import__("random").choices(range(256), k=1000000)' 'bytes(a)' showing a ~31% reduction in time consumed:

100 loops, best of 5: 3.21 msec per loop # current
100 loops, best of 5: 2.23 msec per loop # this PR

With k=10000, a ~30% time reduction:

100 loops, best of 5: 31.7 usec per loop # current
100 loops, best of 5: 22.3 usec per loop # this PR

With k=100, a ~27% time reduction:

100 loops, best of 5: 410 nsec per loop # current
100 loops, best of 5: 299 nsec per loop # this PR

Loading
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

awaiting core review stale Stale PR or inactive for long period of time.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

5 participants