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

Remove use of len(seq) - 1 to get last item of an iterable #1500

Merged
merged 1 commit into from
Jun 21, 2022

Conversation

ThibFrgsGmz
Copy link
Contributor

Originating Project/Creator @ThibFrgsGmz
Affected Component python autocoder
Affected Architectures(s)
Related Issue(s) void
Has Unit Tests (y/n) n
Builds Without Errors (y/n) Let CI run
Unit Tests Pass (y/n) Let CI run
Documentation Included (y/n) n

Change Description

This PR removes the use of len(seq) - 1 to get last item of an iterable.

Rationale

It is not necessary to calculate the length of an iterable in order to get the last element of the iterable.
We can directly give it a negative index -1 to get the last element. We won't have to iterate over the sequence using len to get the last index if the goal is simply to get the last element.

Testing/Review Recommendations

void

Future Work

void

Copy link
Collaborator

@kevin-f-ortega kevin-f-ortega left a comment

Choose a reason for hiding this comment

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

I agree. Using -1 is better.

@LeStarch LeStarch merged commit 32d9a42 into nasa:devel Jun 21, 2022
@ThibFrgsGmz ThibFrgsGmz deleted the feat/improve_get_last_element branch September 3, 2022 19:39
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.

3 participants