Skip to content

Minor Performance Hits Elimination#15

Open
v1k1nghawk wants to merge 1 commit intoonnx:mainfrom
v1k1nghawk:enhancement_minor_performance_hits_elimination
Open

Minor Performance Hits Elimination#15
v1k1nghawk wants to merge 1 commit intoonnx:mainfrom
v1k1nghawk:enhancement_minor_performance_hits_elimination

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

Signed-off-by: Andrey Art <67466892+v1k1nghawk@users.noreply.github.com>
@justinchuby
Copy link
Member

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