Copying Data Structures Quirks
Note
TL;DR — Copying fails if a value is an iterator.
To create a duplicate of a data structure, Python provides methods copy() and deepcopy(). Lately, I wanted to duplicate a nested structure with deepcopy() and encountered following issue:
TypeError: object.__new__(dict_keys) is not safe, use dict_keys.__new__()
And ...
more ...