4 ms·
Dataclasses can optionally be «frozen» / immutable IIRC. Namedtuple is intended for when you need a tuple. I’ve used it for e.g numpy array shapes, so image da
by pletnes 5y ago
Dataclasses can optionally be «frozen» / immutable IIRC.
Namedtuple is intended for when you need a tuple. I’ve used it for e.g numpy array shapes, so image data has names (imgshape.width instead of imgshape[1]). There, you need an actual tuple (or subclass of tuple if you want).