Skip to content
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

Increase join concat performance #2291

Merged
merged 5 commits into from Oct 29, 2021
Merged

Increase join concat performance #2291

merged 5 commits into from Oct 29, 2021

Conversation

ahopkins
Copy link
Member

Because performance matters


As pointed out by @Tronic, doing a join on a list is faster than on a generator

import timy

LOOPS = 100_000
RANGE = 100


@timy.timer(loops=LOOPS)
def do_list():
    "".join([str(i) for i in range(RANGE)])


@timy.timer(loops=LOOPS)
def do_generator():
    "".join(str(i) for i in range(RANGE))


do_list()
do_generator()
Timy executed (do_list) for 100000 times in 1.287258 seconds
Timy best time was 0.000012 seconds
Timy executed (do_generator) for 100000 times in 1.401102 seconds
Timy best time was 0.000014 seconds

@ahopkins ahopkins requested a review from a team as a code owner October 27, 2021 08:14
Copy link
Member

@prryplatypus prryplatypus left a comment

Choose a reason for hiding this comment

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

Join go brrr

@Tronic
Copy link
Member

Tronic commented Oct 27, 2021

Every nanosecond counts in Sanic 🤣

@ahopkins
Copy link
Member Author

Every nanosecond counts in Sanic rofl

If we know something is faster, we are obligated to add it 💪 😆

@codeclimate
Copy link

codeclimate bot commented Oct 29, 2021

Code Climate has analyzed commit 58d6697 and detected 0 issues on this pull request.

The test coverage on the diff in this pull request is 100.0% (86% is the threshold).

This pull request will bring the total coverage in the repository to 86.7% (0.0% change).

View more on Code Climate.

@ahopkins ahopkins merged commit 36e6a6c into main Oct 29, 2021
@ahopkins ahopkins deleted the websocket-handshake-concat branch October 29, 2021 09:55
@sjsadowski
Copy link
Contributor

Just popping in to say gotta go fast

ChihweiLHBird pushed a commit to ChihweiLHBird/sanic that referenced this pull request Jun 1, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

4 participants