Tag

Namedtuple

0 views collected around this technical thread.

Code Mala Tang
Code Mala Tang
Mar 17, 2025 · Backend Development

How to Efficiently Map Dictionaries to Python Classes: From Namedtuple to Pydantic

Mapping external data such as MongoDB query results or API responses to Python class attributes can be done manually, but this article explores several automated approaches—including namedtuple, setattr, a custom ModelBase/Type mapper, and Pydantic—detailing implementation, error handling, and performance benchmarks to guide developers in choosing the optimal solution.

Data mappingNamedtuplePerformance Benchmark
0 likes · 12 min read
How to Efficiently Map Dictionaries to Python Classes: From Namedtuple to Pydantic
Test Development Learning Exchange
Test Development Learning Exchange
Jun 26, 2024 · Fundamentals

Python collections module: Counter, defaultdict, deque, namedtuple, ChainMap, custom containers, heapq, and LRU cache examples

This article introduces several useful classes from Python's collections module—including Counter, defaultdict, deque, namedtuple, ChainMap, UserList/UserDict/UserString, as well as heapq and an OrderedDict‑based LRU cache—explaining their purposes and providing ready‑to‑run code examples for each.

ChainMapCollectionsNamedtuple
0 likes · 6 min read
Python collections module: Counter, defaultdict, deque, namedtuple, ChainMap, custom containers, heapq, and LRU cache examples
Test Development Learning Exchange
Test Development Learning Exchange
May 9, 2024 · Fundamentals

Understanding Python's namedtuple: Benefits and Practical Usage

This article explains Python's namedtuple data structure, highlighting its readability, lightweight nature, performance advantages, built‑in methods, and how it compares to regular tuples through clear code examples that demonstrate creation, element access, updating, serialization, and advanced features.

Data StructuresNamedtuplePython
0 likes · 8 min read
Understanding Python's namedtuple: Benefits and Practical Usage