Tagged articles
dict
16 articles · Page 1 of 1
This article explores Python's __missing__ dunder method, showing how it surpasses traditional approaches like if/else, .get() and defaultdict by enabling dynamic, self‑healing dictionary behavior, and demonstrates advanced real‑world applications such as smart counters, infinite nested dicts, API caching, and automatic data pipelines.
API cachePython__missing__
0 likes · 13 min read

Explore how Python’s built-in __dict__ attribute stores object attributes, enabling introspection, dynamic attribute manipulation, memoization, JSON serialization, custom descriptors, and debugging, while also learning its limitations with slots and built-in types for performance.
IntrospectionPythonSerialization
0 likes · 8 min read

This article explains Python's dict, set, and frozenset containers, lists their most frequently used methods, demonstrates how to subclass dict and create a container class, and describes the hash‑table implementation details that give these data structures their high performance.
Pythondictfrozenset
0 likes · 12 min read

The article explains the internal cache‑pool mechanism of CPython dictionaries, detailing how PyDictObject and PyDictKeysObject are allocated, deallocated, and reused via free‑lists of size 80, and demonstrates the behavior with concrete code examples and benchmarks.
cache-pooldictinternals
0 likes · 12 min read

The article explains Python's dict resizing mechanism, detailing when the hash table grows (when used entries reach two‑thirds of capacity), how the new size is chosen as the smallest power‑of‑two ≥ ma_used × 3, and the exact steps the interpreter takes to reallocate and rebuild the underlying key and entry arrays.
Pythoncombined-tabledict
0 likes · 12 min read

This guide explains how Python’s built‑in zip() and dict() functions can be combined to pair elements from two separate lists and create a dictionary, covering function basics, step‑by‑step examples, practical use cases such as user credentials and student scores, and a concise summary of the technique.
Pythondata structuresdict
0 likes · 6 min read

This article dissects the CPython implementation of three dictionary methods—get, setdefault, and popitem—showing example usage, walking through the C source code, explaining hash look‑ups, entry handling, and the subtle state changes that occur when keys are missing or removed.
CPythonGETImplementation
0 likes · 14 min read

This article dissects CPython's dictionary implementation, explaining how a PyDictObject and its PyDictKeysObject are allocated, how method groups map to Python magic methods, and the detailed C logic for inserting, updating, and retrieving key‑value pairs, including __missing__ handling.
CPythonHashMapPython
0 likes · 16 min read

This article dissects Python's dictionary implementation, explaining the PyDictObject layout, the combined and split hash‑table designs, memory‑optimisation techniques, insertion and lookup processes, ordered iteration, and precise memory‑size calculations with concrete code examples.
CPythonPythondata structures
0 likes · 24 min read

The article explains how Python maps a dict key to a hash‑table slot, the two classic collision‑resolution strategies (separate chaining and open addressing), why Python uses an iterative probing function, and walks through the core C functions that perform the lookup and slot‑finding logic.
C languagePythoncollision-resolution
0 likes · 20 min read

This article explains the purpose and usage of several Python special methods—including __unicode__, __delattr__, __del__, __dict__, and __all__—and provides concrete code examples illustrating how each method works in practice.
Unicode__all____delattr__
0 likes · 4 min read

This article explains Python's __dict__ attribute storage, class and instance attributes, demonstrates how to inspect and modify them, introduces properties using the built‑in property() function, and shows dynamic attribute generation with __getattr__, providing clear code examples and explanations.
Propertyattributesdict
0 likes · 9 min read

This article explains Python’s built-in dict and set structures, comparing them with lists, demonstrating their fast key-value lookups, handling missing keys, and common operations like insertion, deletion, and set algebra, while providing clear code examples and practical tips for effective use.
Immutable ObjectsPythondata structures
0 likes · 9 min read

This article explains how the Python dict() function creates new dictionaries, demonstrates various ways to supply key/value pairs—including empty dictionaries, literal mappings, keyword arguments, lists of tuples, and zip()—and provides examples of common dictionary methods such as clear, copy, fromkeys, get, items, keys, pop, popitem, setdefault, and update.
Pythondictdictionary
0 likes · 5 min read

This article explores ten puzzling Python behaviors—from implicit dictionary key conversion and generator timing quirks to list‑iteration deletions, else clause nuances, the difference between is and ==, loop variable leakage, + versus +=, try‑finally returns, mutable True/False assignments, and subtle for‑loop mechanics—providing clear explanations and code examples for each.
LoopPythondict
0 likes · 11 min read

This article explains how Python implements dictionaries with hash tables, details the hash function for strings, demonstrates collision handling via open addressing and quadratic probing, and walks through the underlying C structures, initialization, insertion, resizing, and deletion processes.
Pythonc-implementationdict
0 likes · 8 min read
