# grammar, eval strategy

    

index ff7d0b4..97478e0 100644
@@ -86,6 +86,7 @@ More:
1. ./inf.md
1. ./typed-dict.md
1. ./getattr-annotation.md
+1. ./eval-strategy.md

Out of order:

@@ -111,3 +112,15 @@ https://bugs.python.org/issue36326
str[0][0][0]
https://www.python.org/dev/peps/pep-0505/
+__dir__
+ModuleType
+Import hooks
+TypeVar
+Bare except
+Value error
+When to use is
+Key error message
+In uses hash, not eq
+Power order in python **
+sre_parse
diff --git a/pythonetc/bytearray.md b/pythonetc/bytearray.md
index 0cef313..249e05e 100644
--- a/pythonetc/bytearray.md
+++ b/pythonetc/bytearray.md
@@ -10,7 +10,7 @@ b.upper()
# bytearray(b'HELLO, @PYTHONETC')


-The type bytearray has all methods of both bytes and list except method sort:
+The type bytearray has all methods of both bytes and list except sort:

python
set(dir(bytearray)) ^ (set(dir(bytes)) | set(dir(list)))
diff --git a/pythonetc/eval-strategy.md b/pythonetc/eval-strategy.md
new file mode 100644
index 0000000..1cb4e7c
--- /dev/null
+++ b/pythonetc/eval-strategy.md
@@ -0,0 +1,71 @@
+In most of the programming languages (like C, PHP, Go, Rust) values can be passed into a function either as value or as reference (pointer):
+
++ [Call by value](https://en.wikipedia.org/wiki/Evaluation_strategy#Call_by_value) means that the value of the variable is copied, so all modification with the argument value inside the function won't affect the original value. This is an example of how it works in [Go](https://golang.org/):
+
+go
+package main
+
+func f(v2 int) {
+  v2 = 2
+  println("f v2:", v2)
+  // Output: f v2: 2
+}
+
+func main() {
+  v1 := 1
+  f(v1)
+  println("main v1:", v1)
+  // Output: main v1: 1
+}
+
+
++ [Call by reference](https://en.wikipedia.org/wiki/Evaluation_strategy#Call_by_reference) means that all modifications done by the function, including reassignment, will modify the original value:
+
+go
+package main
+
+func f(v2 *int) {
+  *v2 = 2
+  println("f v2:", *v2)
+  // Output: f v2: 2
+}
+
+func main() {
+  v1 := 1
+  f(&v1)
+  println("main v1:", v1)
+  // Output: main v1: 2
+}
+
+
+So, which one is used in Python? Well, neither.
+
+In Python, the caller and the function share the same value:
+
+python
+def f(v2: list):
+  v2.append(2)
+  print('f v2:', v2)
+  # f v2: [1, 2]
+
+v1 = [1]
+f(v1)
+print('v1:', v1)
+# v1: [1, 2]
+
+
+However, the function can't replace the value (reassign the variable):
+
+python
+def f(v2: int):
+  v2 = 2
+  print('f v2:', v2)
+  # f v2: 2
+
+v1 = 1
+f(v1)
+print('v1:', v1)
+# v1: 1
+
+
+This approach is called [Call by sharing](https://en.wikipedia.org/wiki/Evaluation_strategy#Call_by_sharing). That means, the argument is always passed into a function as a copy of pointer. So, both variables point to the same boxed object in memory but if the pointer itself is modified inside the function, it doesn't affect the caller code.
diff --git a/pythonetc/season25.md b/pythonetc/season25.md
index 5715fb6..ef13387 100644
--- a/pythonetc/season25.md
+++ b/pythonetc/season25.md
@@ -4,7 +4,7 @@ It was a long break but tomorrow we start again. We have plenty of ideas for pos

+ If you don't have an idea, just contact us, we have plenty of them! And if you like it, the algorithm is the same as above: write a post, send it, we publish it with your name.

-+ If you don't have time to write posts but still want to help, consider donating a bot of money. If we get enough, we can take a one-day vacation and invest it exclusively into writing posts.
++ If you don't have time to write posts but still want to help, consider donating a bit of money, links are in the channel description. If we get enough, we can take a one-day vacation and invest it exclusively into writing posts.

+ If you see a bug or typo in a post, please, let us know!

diff --git a/pythonetc/str-concat.md b/pythonetc/str-concat.md
index b3424bb..af3cd60 100644
--- a/pythonetc/str-concat.md
+++ b/pythonetc/str-concat.md
@@ -1,4 +1,4 @@
-Let's learn a bit more about strings performance. What if instead of unknown amount of strings we have only a few known variables?
+Let's learn a bit more about strings performance. What if instead of an unknown amount of strings we have only a few known variables?

python
s1 = 'hello, '
@@ -17,7 +17,7 @@ s2 = '@pythonetc'
# 57 ns ± 5.43 ns per loop


-No surprises here, + and f-strings are equaly good, str.format is quite close. But what if we have numbers instead?
+No surprises here, + and f-strings are equally good, str.format is quite close. But what if we have numbers instead?

python
n1 = 123
@@ -32,7 +32,7 @@ n2 = 456
# 208 ns ± 3.49 ns per loop


-In this case, formatting is faster because it doesn't create intermediate strings. However, there is something else about f-strings. Let's measure how long it takes just to convert an int into a str:
+In this case, formatting is faster because it doesn't create intermediate strings. However, there is something else about f-strings. Let's measure how long it takes just to convert an int into an str:

python
%timeit str(n1)
@@ -64,4 +64,4 @@ dis.dis("str(n1)")
6 RETURN_VALUE


-And once more, disclamer: readability is more important than performance until proven otherwise. Use your knowledge with caution :)
+And once more, disclaimer: readability is more important than performance until proven otherwise. Use your knowledge with caution :)