Skip to content

Commit eff078c

Browse files
author
暮晨
committed
EX.Time for some hash brownies
1 parent eb69bff commit eff078c

File tree

1 file changed

+10
-9
lines changed

1 file changed

+10
-9
lines changed

README.md

Lines changed: 10 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,7 @@ So, here we go...
2626
- [👀 Examples](#👀-examples)
2727
- [Section: Strain your brain!](#section-strain-your-brain)
2828
- [> Strings can be tricky sometimes/微妙的字符串 *](#-strings-can-be-tricky-sometimes微妙的字符串-)
29-
- [> Time for some hash brownies!](#-time-for-some-hash-brownies)
29+
- [> Time for some hash brownies!/是时候来点蛋糕了!](#-time-for-some-hash-brownies是时候来点蛋糕了)
3030
- [> Return return everywhere!](#-return-return-everywhere)
3131
- [> Deep down, we're all the same. *](#-deep-down-were-all-the-same-)
3232
- [> For what?](#-for-what)
@@ -209,7 +209,8 @@ False
209209
210210
---
211211
212-
### > Time for some hash brownies!
212+
### > Time for some hash brownies!/是时候来点蛋糕了!
213+
* hash brownie指一种含有大麻成分的蛋糕, 所以这里是句双关
213214
214215
1\.
215216
```py
@@ -229,21 +230,21 @@ some_dict[5] = "Python"
229230
"Python"
230231
```
231232
232-
"Python" destroyed the existence of "JavaScript"?
233+
"Python" 消除了 "JavaScript" 的存在?
233234
234-
#### 💡 Explanation
235+
#### 💡 说明:
235236
236-
* Python dictionaries check for equality and compare the hash value to determine if two keys are the same.
237-
* Immutable objects with same value always have the same hash in Python.
237+
* Python 字典通过检查键值是否相等和比较哈希值来确定两个键是否相同.
238+
* 具有相同值的不可变对象在Python中始终具有相同的哈希值.
238239
```py
239240
>>> 5 == 5.0
240241
True
241242
>>> hash(5) == hash(5.0)
242243
True
243244
```
244-
**Note:** Objects with different values may also have same hash (known as hash collision).
245-
* When the statement `some_dict[5] = "Python"` is executed, the existing value "JavaScript" is overwritten with "Python" because Python recognizes `5` and `5.0` as the same keys of the dictionary `some_dict`.
246-
* This StackOverflow [answer](https://stackoverflow.com/a/32211042/4354153) explains beautifully the rationale behind it.
245+
**注意:** 具有不同值的对象也可能具有相同的哈希值(哈希冲突).
246+
* 当执行 `some_dict[5] = "Python"` 语句时, 因为Python将 `5` `5.0` 识别为 `some_dict` 的同一个键, 所以已有值 "JavaScript" 就被 "Python" 覆盖了.
247+
* 这个 StackOverflow的 [回答](https://stackoverflow.com/a/32211042/4354153) 漂亮的解释了这背后的基本原理.
247248
248249
---
249250

0 commit comments

Comments
 (0)