dict() vs. {}

Sebastian Witowski
4 min readDec 1, 2022

There are two different ways to create a dictionary. You can call the dict() function or use the literal syntax: {}. And in many cases, these are equivalent choices, so you might give it little thought and assume they both take the same amount of time.

But they don’t!

Starting with this article in the “Writing Faster Python” series, I have switched from Python 3.8 to 3.11 in my benchmarks. So if you’re following…

Sebastian Witowski

Python consultant and freelancer at switowski.com. Writes about productivity, tools, Python, and programming best practices.