Python

Python

Made by DeepSource

Consider using a dictionary comprehension PYL-R1717

Performance
Major
Autofix

Although there is nothing syntactically wrong with this code, it is hard to read and can be simplified to a dict comprehension. Using dictionary comprehension is more performant since there is no need to create a transient list.

Bad practice

mapping = dict([(num, str(num)) for num in my_magic_nums])

Recommended

mapping = {num: str(num) for num in my_magic_nums}