# consider-using-generator / R1728#

Message emitted:

Consider using a generator instead '%s(%s)'

Description:

If your container can be large using a generator will bring better performance.

Problematic code:

```list([0 for y in list(range(10))])  # [consider-using-generator]
tuple([0 for y in list(range(10))])  # [consider-using-generator]
sum([y**2 for y in list(range(10))])  # [consider-using-generator]
max([y**2 for y in list(range(10))])  # [consider-using-generator]
min([y**2 for y in list(range(10))])  # [consider-using-generator]
```

Correct code:

```list(0 for y in list(range(10)))
tuple(0 for y in list(range(10)))
sum(y**2 for y in list(range(10)))
max(y**2 for y in list(range(10)))
min(y**2 for y in list(range(10)))
```

Removing `[]` inside calls that can use containers or generators should be considered for performance reasons since a generator will have an upfront cost to pay. The performance will be better if you are working with long lists or sets.
For `max`, `min` and `sum` using a generator is also recommended by pep289.
{"ft_lang_label":"__label__en","ft_lang_prob":0.7026987,"math_prob":0.79312897,"size":1094,"snap":"2022-40-2023-06","text_gpt3_token_len":274,"char_repetition_ratio":0.22752294,"word_repetition_ratio":0.06802721,"special_character_ratio":0.29067641,"punctuation_ratio":0.057971016,"nsfw_num_words":0,"has_unicode_error":false,"math_prob_llama3":0.97462535,"pos_list":[0],"im_url_duplicate_count":[null],"WARC_HEADER":"{\"WARC-Type\":\"response\",\"WARC-Date\":\"2023-01-27T14:54:09Z\",\"WARC-Record-ID\":\"<urn:uuid:ec4ec4e7-6643-4a11-a62d-44c2151eaf6c>\",\"Content-Length\":\"143575\",\"Content-Type\":\"application/http; msgtype=response\",\"WARC-Warcinfo-ID\":\"<urn:uuid:806f106d-955c-431c-9113-15723bfa70f3>\",\"WARC-Concurrent-To\":\"<urn:uuid:169082ac-bd61-4b8a-8a42-cc559f6c8b80>\",\"WARC-IP-Address\":\"104.17.32.82\",\"WARC-Target-URI\":\"https://pylint.readthedocs.io/en/latest/user_guide/messages/refactor/consider-using-generator.html\",\"WARC-Payload-Digest\":\"sha1:UX6OECI6WZPV6JBEUCRMS5NWHWPLPXAL\",\"WARC-Block-Digest\":\"sha1:HFYITSAEWZCAVQNM2J4EAHNAPXNF4U3Y\",\"WARC-Identified-Payload-Type\":\"text/html\",\"warc_filename\":\"/cc_download/warc_2023/CC-MAIN-2023-06/CC-MAIN-2023-06_segments_1674764494986.94_warc_CC-MAIN-20230127132641-20230127162641-00627.warc.gz\"}"}