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

Simplify and optimize the most common methods of 'Headers' #3353

Closed

Conversation

princerb
Copy link

@princerb princerb commented Oct 21, 2024

This PR enhances the performance of the modified functions by significantly increasing their execution speed x100000. I used generators of course and I can add more of these kinds in the future if you like!
The current test (tests/models/test_headers.py) can handle this change so I didn't write any.

Before:

$ python -m timeit -r 10 -n 10 -c "from main import h" "h.items()"
10 loops, best of 10: 297 msec per loop

After:

$ python -m timeit -r 10 -n 10 -c "from main import h" "h.items()"
10 loops, best of 10: 660 nsec per loop
:0: UserWarning: The test results are likely unreliable. The worst time (4.01 msec) was more than four times slower than the best time (660 nsec).

If these kind of PRs can be merged, I would like to contribute with like these optimised solutions again to speed up the lib. Or feel free to give a feedback)

Checklist

  • I understand that this PR may be closed in case there was no previous discussion. (This doesn't apply to typos!)
  • I've added a test for each change that was introduced, and I tried as much as possible to make a single atomic change.
  • I've updated the documentation accordingly.

@princerb princerb force-pushed the improve-optimise-mthds-headers branch from 411db04 to ba7f721 Compare October 21, 2024 20:06
@princerb
Copy link
Author

So the tests, I guess then although generators are faster, they are not for good presentation(

@princerb princerb deleted the improve-optimise-mthds-headers branch October 22, 2024 06:30
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.

2 participants