.. _use-dict-literal:

use-dict-literal / R1735
========================

**Message emitted:**

Consider using '%s' instead of a call to 'dict'.

**Description:**

*Emitted when using dict() to create a dictionary instead of a literal '{ ... }'. The literal is faster as it avoids an additional function call.*

**Problematic code:**

.. literalinclude:: /data/messages/u/use-dict-literal/bad.py
   :language: python

**Correct code:**

.. literalinclude:: /data/messages/u/use-dict-literal/good.py
   :language: python

**Additional details:**

https://gist.github.com/hofrob/ad143aaa84c096f42489c2520a3875f9

This example script shows an 18% increase in performance when using a literal over the
constructor in python version 3.10.6.


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