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

Minor Performance Hits Elimination #15

Open
wants to merge 1 commit into
base: main
Choose a base branch
from

Conversation

v1k1nghawk
Copy link

Type of Change

feature + code quality improvements
API changed or not: no

Description

Reduce the performance impact of dictionaries creation and lists building (plus remove import duplication and improve formatting).

How has this PR been tested?

list comprehension vs list():

python3 -m timeit --number=10000000 "
[l for l in 'data']
"

10000000 loops, best of 5: 401 nsec per loop

python3 -m timeit --number=10000000 "
list('data')
"

10000000 loops, best of 5: 326 nsec per loop

dict() vs {}:

python3 -m timeit --number=10000000 "
dict()
"

10000000 loops, best of 5: 139 nsec per loop

python3 -m timeit --number=10000000 "
{}
"

10000000 loops, best of 5: 65.4 nsec per loop

Setup:

  • Python 3.12.3
  • Linux 6.8.9-300.fc40.x86_64

Dependency Change?

any library dependency introduced or removed: no

@justinchuby
Copy link
Contributor

All of these changes can be auto-fixed by ruff. I suggest we wait and use the tool to fix everything, once the CI pipeline is set up.

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