Exploring and understanding Python through surprising snippets.
@@ -352,7 +358,14 @@ Makes sense, right?
* All length 0 and length 1 strings are interned.
* Strings are interned at compile time (`'wtf'` will be interned but `''.join(['w', 't', 'f'])` will not be interned)
* Strings that are not composed of ASCII letters, digits or underscores, are not interned. This explains why `'wtf!'` was not interned due to `!`. CPython implementation of this rule can be found [here](https://github.com/python/cpython/blob/3.6/Objects/codeobject.c#L19)
- 
+
+
+
+
+
+
+
+
+ When `a` and `b` are set to `"wtf!"` in the same line, the Python interpreter creates a new object, then references the second variable at the same time. If you do it on separate lines, it doesn't "know" that there's already `"wtf!"` as an object (because `"wtf!"` is not implicitly interned as per the facts mentioned above). It's a compile-time optimization. This optimization doesn't apply to 3.7.x versions of CPython (check this [issue](https://github.com/satwikkansal/wtfpython/issues/100) for more discussion).
+ A compile unit in an interactive environment like IPython consists of a single statement, whereas it consists of the entire module in case of modules. `a, b = "wtf!", "wtf!"` is single statement, whereas `a = "wtf!"; b = "wtf!"` are two statements in a single line. This explains why the identities are different in `a = "wtf!"; b = "wtf!"`, and also explain why they are same when invoked in `some_file.py`
+ The abrupt change in the output of the fourth snippet is due to a [peephole optimization](https://en.wikipedia.org/wiki/Peephole_optimization) technique known as Constant folding. This means the expression `'a'*20` is replaced by `'aaaaaaaaaaaaaaaaaaaa'` during compilation to save a few clock cycles during runtime. Constant folding only occurs for strings having a length of less than 21. (Why? Imagine the size of `.pyc` file generated as a result of the expression `'a'*10**10`). [Here's](https://github.com/python/cpython/blob/3.6/Python/peephole.c#L288) the implementation source for the same.
@@ -975,11 +988,23 @@ We didn't assign three `"X"`s, did we?
When we initialize `row` variable, this visualization explains what happens in the memory
-
+
+
+
+
+
+
+
And when the `board` is initialized by multiplying the `row`, this is what happens inside the memory (each of the elements `board[0]`, `board[1]` and `board[2]` is a reference to the same list referred by `row`)
-
+
+
+
+
+
+
+
We can avoid this scenario here by not using `row` variable to generate `board`. (Asked in [this](https://github.com/satwikkansal/wtfpython/issues/68) issue).
diff --git a/images/expanding-brain-meme.jpg b/images/expanding-brain-meme.jpg
deleted file mode 100644
index 9437c2f..0000000
Binary files a/images/expanding-brain-meme.jpg and /dev/null differ
diff --git a/images/logo-dark.png b/images/logo-dark.png
deleted file mode 100644
index 9d7791f..0000000
Binary files a/images/logo-dark.png and /dev/null differ
diff --git a/images/logo.png b/images/logo.png
deleted file mode 100644
index 014a63a..0000000
Binary files a/images/logo.png and /dev/null differ
diff --git a/images/logo.svg b/images/logo.svg
new file mode 100755
index 0000000..6ec5eda
--- /dev/null
+++ b/images/logo.svg
@@ -0,0 +1,38 @@
+
+
+
diff --git a/images/logo_dark_theme.svg b/images/logo_dark_theme.svg
new file mode 100755
index 0000000..f89e797
--- /dev/null
+++ b/images/logo_dark_theme.svg
@@ -0,0 +1,38 @@
+
+
+
diff --git a/images/string-intern/string_intern.png b/images/string-intern/string_intern.png
deleted file mode 100644
index 6511978..0000000
Binary files a/images/string-intern/string_intern.png and /dev/null differ
diff --git a/images/string-intern/string_interning.svg b/images/string-intern/string_interning.svg
new file mode 100755
index 0000000..0572a9e
--- /dev/null
+++ b/images/string-intern/string_interning.svg
@@ -0,0 +1,4 @@
+
+
+
+
diff --git a/images/string-intern/string_interning_dark_theme.svg b/images/string-intern/string_interning_dark_theme.svg
new file mode 100755
index 0000000..69c32e4
--- /dev/null
+++ b/images/string-intern/string_interning_dark_theme.svg
@@ -0,0 +1,4 @@
+
+
+
+
diff --git a/images/tic-tac-toe.png b/images/tic-tac-toe.png
deleted file mode 100644
index 9c25117..0000000
Binary files a/images/tic-tac-toe.png and /dev/null differ
diff --git a/images/tic-tac-toe/after_board_initialized.png b/images/tic-tac-toe/after_board_initialized.png
deleted file mode 100644
index 616747f..0000000
Binary files a/images/tic-tac-toe/after_board_initialized.png and /dev/null differ
diff --git a/images/tic-tac-toe/after_board_initialized.svg b/images/tic-tac-toe/after_board_initialized.svg
new file mode 100755
index 0000000..02b1dad
--- /dev/null
+++ b/images/tic-tac-toe/after_board_initialized.svg
@@ -0,0 +1,4 @@
+
+
+
+
\ No newline at end of file
diff --git a/images/tic-tac-toe/after_board_initialized_dark_theme.svg b/images/tic-tac-toe/after_board_initialized_dark_theme.svg
new file mode 100755
index 0000000..3218ad0
--- /dev/null
+++ b/images/tic-tac-toe/after_board_initialized_dark_theme.svg
@@ -0,0 +1,4 @@
+
+
+
+
\ No newline at end of file
diff --git a/images/tic-tac-toe/after_row_initialized.png b/images/tic-tac-toe/after_row_initialized.png
deleted file mode 100644
index 520d700..0000000
Binary files a/images/tic-tac-toe/after_row_initialized.png and /dev/null differ
diff --git a/images/tic-tac-toe/after_row_initialized.svg b/images/tic-tac-toe/after_row_initialized.svg
new file mode 100755
index 0000000..92eb02c
--- /dev/null
+++ b/images/tic-tac-toe/after_row_initialized.svg
@@ -0,0 +1,4 @@
+
+
+
+
\ No newline at end of file
diff --git a/images/tic-tac-toe/after_row_initialized_dark_theme.svg b/images/tic-tac-toe/after_row_initialized_dark_theme.svg
new file mode 100755
index 0000000..2404958
--- /dev/null
+++ b/images/tic-tac-toe/after_row_initialized_dark_theme.svg
@@ -0,0 +1,4 @@
+
+
+
+
\ No newline at end of file
diff --git a/irrelevant/wtf.ipynb b/irrelevant/wtf.ipynb
index a3147e1..4ea2333 100644
--- a/irrelevant/wtf.ipynb
+++ b/irrelevant/wtf.ipynb
@@ -4,7 +4,7 @@
"cell_type": "markdown",
"metadata": {},
"source": [
- "
\n",
+ "\n",
"
What the f*ck Python! \ud83d\ude31
\n",
"
Exploring and understanding Python through surprising snippets.
\n",
"\n",
@@ -355,7 +355,7 @@
" * All length 0 and length 1 strings are interned.\n",
" * Strings are interned at compile time (`'wtf'` will be interned but `''.join(['w', 't', 'f'])` will not be interned)\n",
" * Strings that are not composed of ASCII letters, digits or underscores, are not interned. This explains why `'wtf!'` was not interned due to `!`. CPython implementation of this rule can be found [here](https://github.com/python/cpython/blob/3.6/Objects/codeobject.c#L19)\n",
- " \n",
+ "\n",
"+ When `a` and `b` are set to `\"wtf!\"` in the same line, the Python interpreter creates a new object, then references the second variable at the same time. If you do it on separate lines, it doesn't \"know\" that there's already `\"wtf!\"` as an object (because `\"wtf!\"` is not implicitly interned as per the facts mentioned above). It's a compile-time optimization. This optimization doesn't apply to 3.7.x versions of CPython (check this [issue](https://github.com/satwikkansal/wtfpython/issues/100) for more discussion).\n",
"+ A compile unit in an interactive environment like IPython consists of a single statement, whereas it consists of the entire module in case of modules. `a, b = \"wtf!\", \"wtf!\"` is single statement, whereas `a = \"wtf!\"; b = \"wtf!\"` are two statements in a single line. This explains why the identities are different in `a = \"wtf!\"; b = \"wtf!\"`, and also explain why they are same when invoked in `some_file.py`\n",
"+ The abrupt change in the output of the fourth snippet is due to a [peephole optimization](https://en.wikipedia.org/wiki/Peephole_optimization) technique known as Constant folding. This means the expression `'a'*20` is replaced by `'aaaaaaaaaaaaaaaaaaaa'` during compilation to save a few clock cycles during runtime. Constant folding only occurs for strings having a length of less than 21. (Why? Imagine the size of `.pyc` file generated as a result of the expression `'a'*10**10`). [Here's](https://github.com/python/cpython/blob/3.6/Python/peephole.c#L288) the implementation source for the same.\n",
@@ -2947,11 +2947,11 @@
"\n",
"When we initialize `row` variable, this visualization explains what happens in the memory\n",
"\n",
- "\n",
+ "\n",
"\n",
"And when the `board` is initialized by multiplying the `row`, this is what happens inside the memory (each of the elements `board[0]`, `board[1]` and `board[2]` is a reference to the same list referred by `row`)\n",
"\n",
- "\n",
+ "\n",
"\n",
"We can avoid this scenario here by not using `row` variable to generate `board`. (Asked in [this](https://github.com/satwikkansal/wtfpython/issues/68) issue).\n",
"\n"
@@ -13475,4 +13475,4 @@
"metadata": {},
"nbformat": 4,
"nbformat_minor": 2
-}
\ No newline at end of file
+}
diff --git a/translations/ru-russian/README.md b/translations/ru-russian/README.md
index d8dff4a..1936149 100644
--- a/translations/ru-russian/README.md
+++ b/translations/ru-russian/README.md
@@ -1,4 +1,10 @@
-