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

Replace lists created with list() with [] #1471

Merged
merged 2 commits into from
May 27, 2022

Conversation

ThibFrgsGmz
Copy link
Contributor

@ThibFrgsGmz ThibFrgsGmz commented May 21, 2022

Originating Project/Creator @ThibFrgsGmz
Affected Component Autocoders/Python
Affected Architectures(s) autocoders
Related Issue(s) (void)
Has Unit Tests (y/n) n
Builds Without Errors (y/n) y
Unit Tests Pass (y/n) (void)
Documentation Included (y/n) n

Change Description

This PR replaces lists created with list() with [] ref.

Rationale

The [] notation is the most concise and Pythonic way to create a list.

It corresponds to the way we create lists with elements, which saves some of the mental energy that would otherwise be consumed by considering two different ways of creating lists.

This method has the added benefit of providing a minor performance boost. Here are the times prior to and following the change:

$ python3 -m timeit "x = list()"
5000000 loops, best of 5: 82 nsec per loop

$ python3 -m timeit "x = []"
10000000 loops, best of 5: 25.4 nsec per loop

Testing/Review Recommendations

(none)

Future Work

I'm not sure I caught them all.

@LeStarch LeStarch merged commit e766ca6 into nasa:devel May 27, 2022
LeStarch pushed a commit that referenced this pull request Jun 29, 2022
* Replace lists created with list() with []

* last f-string concat
@ThibFrgsGmz ThibFrgsGmz deleted the feat/list-literal branch September 3, 2022 19:40
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