.. _unnecessary-comprehension:

unnecessary-comprehension / R1721
=================================

**Message emitted:**

``Unnecessary use of a comprehension, use %s instead.``

**Description:**

*Instead of using an identity comprehension, consider using the list, dict or set constructor. It is faster and simpler.*

**Problematic code:**

.. literalinclude:: /data/messages/u/unnecessary-comprehension/bad.py
   :language: python

**Correct code:**

.. literalinclude:: /data/messages/u/unnecessary-comprehension/good.py
   :language: python





Created by the `refactoring <https://github.com/PyCQA/pylint/blob/main/pylint/checkers/refactoring/refactoring_checker.py>`__ checker.