GCI12000 [Team TREE][2025] - For loop vs list comprehension#407
Open
echeniquegrecia wants to merge 1 commit into
Open
GCI12000 [Team TREE][2025] - For loop vs list comprehension#407echeniquegrecia wants to merge 1 commit into
echeniquegrecia wants to merge 1 commit into
Conversation
86b0d88 to
c116177
Compare
dedece35
requested changes
May 21, 2025
| "creedengo", | ||
| "eco-design", | ||
| "performance", | ||
| "comprehension", |
Member
There was a problem hiding this comment.
please delete tags "comprehension", "loop", and "iteration" because there aren't thematic tags but code centric
| @@ -0,0 +1,18 @@ | |||
| { | |||
| "title": "To use list comprehension instead for loop in simple iterations", | |||
dedece35
requested changes
May 21, 2025
|
|
||
| ### Added | ||
|
|
||
| - Added rule GCI1200: Detect a for loop and suggest a list comprehension |
Member
There was a problem hiding this comment.
add here a link to current PR like done in other example in CHANGELOG.md
| | | Resize images browser-side | Do not resize images using the HEIGHT and WIDTH attributes of the HTML code. This approach requires transferring these images to their original size, wasting bandwidth and CPU cycles. | [cnumr best practices (3rd edition) BP_034](https://github.com/cnumr/best-practices/blob/main/chapters/BP_034_fr.md) | 🚫 | 🚫 | 🚧 | 🚫 | 🚫 | 🚫 | 🚀 | | ||
| | | Modify the DOM when traversing it | Modifying the DOM (Document Object Model) as you traverse it can lead to situations where the loop becomes very resource-intensive, especially CPU cycles. | [cnumr best practices (3rd edition) BP_041](https://github.com/cnumr/best-practices/blob/main/chapters/BP_041_fr.md) | 🚫 | 🚫 | 🚧 | 🚫 | 🚫 | 🚫 | 🚫 | | ||
| | | Edit DOM elements to make it invisible | When an element of the Document Object Model (DOM) needs to be modified by several properties, each change in style or content will generate a repaint or reflow. | [cnumr best practices (3rd edition) BP_042](https://github.com/cnumr/best-practices/blob/main/chapters/BP_042_fr.md) | 🚫 | 🚫 | 🚀 | 🚫 | 🚫 | 🚫 | 🚫 | | ||
| | GSI1200 | To use list comprehension instead for loop in simple iterations | | | ❓ | ❓ | 🚀 | ❓ | ❓ |❓ |❓ | |
Member
There was a problem hiding this comment.
typo error : GCI and not GSI, please
Contributor
|
This PR has been automatically marked as stale because it has no activity for 60 days. |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
When you use a for loop, on every iteration, you have to look up the variable holding
the list and then call its append() function. A list comprehension can be faster
than a for loop because it’s optimized for performance by Python’s internal mechanisms.
References: