Skip to content

Commit dfe9ebb

Browse files
committed
Migrate dict_union to fundamentals
1 parent f7dbd80 commit dfe9ebb

10 files changed

Lines changed: 16 additions & 25 deletions

File tree

‎README.de.md‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -88,6 +88,7 @@ Es gibt zwei Möglichkeiten, die Module auszuführen:
8888
- Tuple: [Tuple operations](ultimatepython/fundamentals/tuple.py)
8989
- Set: [Set operations](ultimatepython/fundamentals/set.py)
9090
- Dict: [Dictionary operations](ultimatepython/fundamentals/dict.py) ( 🍰 )
91+
- Dict union: [Dictionary merge | and |=](ultimatepython/fundamentals/dict_union.py) ( 🤯 )
9192
- Conditional: [if | if-else | if-elif-else](ultimatepython/fundamentals/conditional.py) ( 🍰 )
9293
- Loop: [for-loop | while-loop](ultimatepython/fundamentals/loop.py) ( 🍰 )
9394
- Function: [def | lambda](ultimatepython/fundamentals/function.py) ( 🍰 )
@@ -136,7 +137,6 @@ Es gibt zwei Möglichkeiten, die Module auszuführen:
136137
- Speicherprofilierung: [tracemalloc | take_snapshot](ultimatepython/engineering/memory_profile.py) ( 🤯 )
137138
- Logger: [logging | getLogger | Handler](ultimatepython/engineering/logger.py) ( 🤯 )
138139
- Bitwise: [Bitwise operators](ultimatepython/engineering/bitwise.py) ( 🍰 ), [One's/Two's Complement](https://www.geeksforgeeks.org/difference-between-1s-complement-representation-and-2s-complement-representation-technique/) ( 📚 )
139-
- Dict union: [Dictionary merge | and |=](ultimatepython/engineering/dict_union.py) ( 🤯 )
140140
- Time complexity: [cPython operations](https://wiki.python.org/moin/TimeComplexity) ( 📚, 🤯 )
141141

142142
## Zusätzliche Ressourcen

‎README.es.md‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -86,6 +86,7 @@ Hay dos maneras de ejecutar los módulos:
8686
- Tupla: [Operaciones con tuplas](ultimatepython/fundamentals/tuple.py)
8787
- Set: [Operaciones con sets](ultimatepython/fundamentals/set.py)
8888
- Diccionario: [Operaciones con dicts](ultimatepython/fundamentals/dict.py) ( 🍰 )
89+
- Unión de diccionarios: [Fusión de diccionarios | y |=](ultimatepython/fundamentals/dict_union.py) ( 🤯 )
8990
- Condicionales: [if | if-else | if-elif-else](ultimatepython/fundamentals/conditional.py) ( 🍰 )
9091
- Iteraciones: [for-loop | while-loop](ultimatepython/fundamentals/loop.py) ( 🍰 )
9192
- Funciones: [def | lambda](ultimatepython/fundamentals/function.py) ( 🍰 )
@@ -134,7 +135,6 @@ Hay dos maneras de ejecutar los módulos:
134135
- Perfil de memoria: [tracemalloc | take_snapshot](ultimatepython/engineering/memory_profile.py) ( 🤯 )
135136
- Registrador: [logging | getLogger | Handler](ultimatepython/engineering/logger.py) ( 🤯 )
136137
- Bit a bit: [Operadores bit a bit](ultimatepython/engineering/bitwise.py) ( 🍰 ), [Complemento a uno/dos](https://www.geeksforgeeks.org/difference-between-1s-complement-representation-and-2s-complement-representation-technique/) ( 📚 )
137-
- Unión de diccionarios: [Fusión de diccionarios | y |=](ultimatepython/engineering/dict_union.py) ( 🤯 )
138138
- Complejidad de tiempo: [Operaciones de cPython](https://wiki.python.org/moin/TimeComplexity) ( 📚, 🤯 )
139139

140140
## Recursos adicionales

‎README.fr.md‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -94,6 +94,7 @@ Deux méthodes sont possibles :
9494
- Tuple : [Opérations sur les tuples](ultimatepython/fundamentals/tuple.py)
9595
- Ensemble : [Opérations sur les ensembles](ultimatepython/fundamentals/set.py)
9696
- Dictionnaire : [Opérations sur les dictionnaires](ultimatepython/fundamentals/dict.py) ( 🍰 )
97+
- Union de dictionnaires : [Fusion de dictionnaires | et |=](ultimatepython/fundamentals/dict_union.py) ( 🤯 )
9798
- Conditionnelle : [if | if-else | if-elif-else](ultimatepython/fundamentals/conditional.py) ( 🍰 )
9899
- Boucle : [for-loop | while-loop](ultimatepython/fundamentals/loop.py) ( 🍰 )
99100
- Fonction : [def | lambda](ultimatepython/fundamentals/function.py) ( 🍰 )
@@ -142,7 +143,6 @@ Deux méthodes sont possibles :
142143
- Profilage mémoire : [tracemalloc | take_snapshot](ultimatepython/engineering/memory_profile.py) ( 🤯 )
143144
- Journalisation : [logging | getLogger | Handler](ultimatepython/engineering/logger.py) ( 🤯 )
144145
- Opérateurs binaires : [Opérateurs binaires](ultimatepython/engineering/bitwise.py) ( 🍰 ), [Complément à un et à deux](https://www.geeksforgeeks.org/difference-between-1s-complement-representation-and-2s-complement-representation-technique/) ( 📚 )
145-
- Union de dictionnaires : [Fusion de dictionnaires | et |=](ultimatepython/engineering/dict_union.py) ( 🤯 )
146146
- Complexité temporelle : [Opérations CPython](https://wiki.python.org/moin/TimeComplexity) ( 📚, 🤯 )
147147

148148
## Ressources supplémentaires

‎README.hi.md‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -68,6 +68,7 @@ print("Ultimate Python स्टडी गाइड")
6868
- ट्यूपल: [ट्यूपल ऑपरेशन्स](ultimatepython/fundamentals/tuple.py)
6969
- सेट: [सेट ऑपरेशन्स](ultimatepython/fundamentals/set.py)
7070
- डिक्ट: [डिक्शनरी ऑपरेशन्स](ultimatepython/fundamentals/dict.py) ( 🍰 )
71+
- डिक्शनरी यूनियन: [डिक्शनरी मर्ज | और |=](ultimatepython/fundamentals/dict_union.py) ( 🤯 )
7172
- कंडीशनल: [if | if-else | if-elif-else](ultimatepython/fundamentals/conditional.py) ( 🍰 )
7273
- लूप: [for-loop | while-loop](ultimatepython/fundamentals/loop.py) ( 🍰 )
7374
- फ़ंक्शन: [def | lambda](ultimatepython/fundamentals/function.py) ( 🍰 )
@@ -116,7 +117,6 @@ print("Ultimate Python स्टडी गाइड")
116117
- मेमोरी प्रोफ़ाइल: [tracemalloc | take_snapshot](ultimatepython/engineering/memory_profile.py) ( 🤯 )
117118
- लॉगर: [logging | getLogger | Handler](ultimatepython/engineering/logger.py) ( 🤯 )
118119
- बाइनरी: [बाइनरी ऑपरेटर](ultimatepython/engineering/bitwise.py) ( 🍰 ), [एक्स/टू का पूरक](https://www.geeksforgeeks.org/difference-between-1s-complement-representation-and-2s-complement-representation-technique/) ( 📚 )
119-
- डिक्शनरी यूनियन: [डिक्शनरी मर्ज | और |=](ultimatepython/engineering/dict_union.py) ( 🤯 )
120120
- समय कोम्पलेक्सिटी: [cPython ऑपरेशन्स](https://wiki.python.org/moin/TimeComplexity) ( 📚, 🤯 )
121121

122122
## अतिरिक्त संसाधन

‎README.ko.md‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -77,6 +77,7 @@ print("Ultimate Python 학습 가이드")
7777
- 튜플: [튜플 연산](ultimatepython/fundamentals/tuple.py)
7878
- 세트: [세트 연산](ultimatepython/fundamentals/set.py)
7979
- 딕셔너리: [딕셔너리 연산](ultimatepython/fundamentals/dict.py) ( 🍰 )
80+
- 딕셔너리 결합: [딕셔너리 병합 | 와 |=](ultimatepython/fundamentals/dict_union.py) ( 🤯 )
8081
- 조건문: [if | if-else | if-elif-else](ultimatepython/fundamentals/conditional.py) ( 🍰 )
8182
- 루프: [for-loop | while-loop](ultimatepython/fundamentals/loop.py) ( 🍰 )
8283
- 함수: [def | lambda](ultimatepython/fundamentals/function.py) ( 🍰 )
@@ -125,7 +126,6 @@ print("Ultimate Python 학습 가이드")
125126
- 메모리 프로파일: [tracemalloc | take_snapshot](ultimatepython/engineering/memory_profile.py) ( 🤯 )
126127
- 로거: [logging | getLogger | Handler](ultimatepython/engineering/logger.py) ( 🤯 )
127128
- 비트 연산: [비트 연산자](ultimatepython/engineering/bitwise.py) ( 🍰 ), [1의 보수/2의 보수](https://www.geeksforgeeks.org/difference-between-1s-complement-representation-and-2s-complement-representation-technique/) ( 📚 )
128-
- 딕셔너리 결합: [딕셔너리 병합 | 와 |=](ultimatepython/engineering/dict_union.py) ( 🤯 )
129129
- 시간 복잡도: [cPython 연산](https://wiki.python.org/moin/TimeComplexity) ( 📚, 🤯 )
130130

131131
## 추가 자료

‎README.md‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -88,6 +88,7 @@ There are two ways of running the modules:
8888
- Tuple: [Tuple operations](ultimatepython/fundamentals/tuple.py)
8989
- Set: [Set operations](ultimatepython/fundamentals/set.py)
9090
- Dict: [Dictionary operations](ultimatepython/fundamentals/dict.py) ( 🍰 )
91+
- Dict union: [Dictionary merge | and |=](ultimatepython/fundamentals/dict_union.py) ( 🤯 )
9192
- Conditional: [if | if-else | if-elif-else](ultimatepython/fundamentals/conditional.py) ( 🍰 )
9293
- Loop: [for-loop | while-loop](ultimatepython/fundamentals/loop.py) ( 🍰 )
9394
- Function: [def | lambda](ultimatepython/fundamentals/function.py) ( 🍰 )
@@ -136,7 +137,6 @@ There are two ways of running the modules:
136137
- Memory profile: [tracemalloc | take_snapshot](ultimatepython/engineering/memory_profile.py) ( 🤯 )
137138
- Logger: [logging | getLogger | Handler](ultimatepython/engineering/logger.py) ( 🤯 )
138139
- Bitwise: [Bitwise operators](ultimatepython/engineering/bitwise.py) ( 🍰 ), [One's/Two's Complement](https://www.geeksforgeeks.org/difference-between-1s-complement-representation-and-2s-complement-representation-technique/) ( 📚 )
139-
- Dict union: [Dictionary merge | and |=](ultimatepython/engineering/dict_union.py) ( 🤯 )
140140
- Time complexity: [cPython operations](https://wiki.python.org/moin/TimeComplexity) ( 📚, 🤯 )
141141

142142
## Additional resources

‎README.pt_br.md‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -75,6 +75,7 @@ Existem duas maneiras de rodar os módulos:
7575
- Tupla: [Operações de tuplas](ultimatepython/fundamentals/tuple.py)
7676
- Conjunto: [Operações de conjuntos](ultimatepython/fundamentals/set.py)
7777
- Dicionário: [Operações de dicionários](ultimatepython/fundamentals/dict.py) ( 🍰 )
78+
- União de dicionários: [Fusão de dicionários | e |=](ultimatepython/fundamentals/dict_union.py) ( 🤯 )
7879
- Condicional: [if | if-else | if-elif-else](ultimatepython/fundamentals/conditional.py) ( 🍰 )
7980
- Loop/Laço: [for-loop | while-loop](ultimatepython/fundamentals/loop.py) ( 🍰 )
8081
- Função: [def | lambda](ultimatepython/fundamentals/function.py) ( 🍰 )
@@ -123,7 +124,6 @@ Existem duas maneiras de rodar os módulos:
123124
- Perfil de memória: [tracemalloc | take_snapshot](ultimatepython/engineering/memory_profile.py) ( 🤯 )
124125
- Logger: [logging | getLogger | Handler](ultimatepython/engineering/logger.py) ( 🤯 )
125126
- Bitwise: [Operadores bitwise](ultimatepython/engineering/bitwise.py) ( 🍰 ), [Complemento de Um/Dois](https://www.geeksforgeeks.org/difference-between-1s-complement-representation-and-2s-complement-representation-technique/) ( 📚 )
126-
- União de dicionários: [Fusão de dicionários | e |=](ultimatepython/engineering/dict_union.py) ( 🤯 )
127127
- Time complexity: [Operações de cPython](https://wiki.python.org/moin/TimeComplexity) ( 📚, 🤯 )
128128

129129
## Recursos adicionais

‎README.zh_tw.md‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -72,6 +72,7 @@ print("Ultimate Python 學習大綱")
7272
- 元組:[元組操作](ultimatepython/fundamentals/tuple.py)
7373
- 集合:[集合操作](ultimatepython/fundamentals/set.py)
7474
- 字典:[字典操作](ultimatepython/fundamentals/dict.py) ( 🍰 )
75+
- 字典聯合:[字典合併 | 和 |=](ultimatepython/fundamentals/dict_union.py) ( 🤯 )
7576
- 條件運算式:[if | if-else | if-elif-else](ultimatepython/fundamentals/conditional.py) ( 🍰 )
7677
- 迴圈:[for迴圈 | while迴圈](ultimatepython/fundamentals/loop.py) ( 🍰 )
7778
- 定義函式:[def | lambda](ultimatepython/fundamentals/function.py) ( 🍰 )
@@ -120,7 +121,6 @@ print("Ultimate Python 學習大綱")
120121
- 記憶體分析:[tracemalloc | take_snapshot](ultimatepython/engineering/memory_profile.py) ( 🤯 )
121122
- 日誌記錄:[logging | getLogger | Handler](ultimatepython/engineering/logger.py) ( 🤯 )
122123
- 按位: [中的位元運算符](ultimatepython/engineering/bitwise.py) ( 🍰 ), [一個的補語/補碼](https://www.geeksforgeeks.org/difference-between-1s-complement-representation-and-2s-complement-representation-technique/) ( 📚 )
123-
- 字典聯合:[字典合併 | 和 |=](ultimatepython/engineering/dict_union.py) ( 🤯 )
124124
- 時間複雜度:[cPython操作](https://wiki.python.org/moin/TimeComplexity) ( 📚, 🤯 )
125125

126126
## 額外資源

‎ui/parse_lessons.py‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -140,6 +140,7 @@ def parse_file(filepath: str, relative_path: str) -> dict:
140140
"tuple",
141141
"set",
142142
"dict",
143+
"dict_union",
143144
"conditional",
144145
"loop",
145146
"function",
@@ -194,7 +195,6 @@ def parse_file(filepath: str, relative_path: str) -> dict:
194195
"memory_profile",
195196
"logger",
196197
"bitwise",
197-
"dict_union",
198198
],
199199
}
200200

Lines changed: 7 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -1,20 +1,11 @@
11
"""
2-
Dictionary union operators (`|` and `|=`) provide clean, side-effect-free dictionary
3-
merging, solving a fundamental software engineering challenge in state management.
4-
5-
In production engineering, managing application state and configuration pipelines
6-
often requires combining multiple data sources (such as default settings, environment
7-
variables, and user overrides). Prior to Python 3.9 (PEP 584), merging required
8-
destructive in-place mutations via `dict.update()` or verbose `{**d1, **d2}` unpacking,
9-
which often introduced subtle shared-state bugs across layers.
10-
11-
Key software engineering benefits:
12-
- Immutability & Safety: `|` produces a new dictionary without mutating either operand,
13-
preventing side-effects across components and concurrent execution paths.
14-
- Deterministic Precedence: Subsequent dictionaries cleanly override earlier ones,
15-
making layered configuration cascades explicit and predictable.
16-
- Expressive In-Place Updates: `|=` clearly signals intentional local mutation
17-
without sacrificing readability.
2+
Dictionary union operators (`|` and `|=`, introduced in Python 3.9 via PEP 584)
3+
provide clean syntax for merging dictionaries.
4+
5+
The binary operator `|` creates a new dictionary combining keys and values from
6+
both operands without mutating either one. The in-place operator `|=` updates the
7+
left-hand dictionary in place. When duplicate keys exist, the right-hand operand's
8+
value takes precedence.
189
"""
1910

2011
from typing import Any

0 commit comments

Comments
 (0)