-
-
Notifications
You must be signed in to change notification settings - Fork 19
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #389 from bozhodimitrov/main
Examples for episode 564 & 565
- Loading branch information
Showing
2 changed files
with
61 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,45 @@ | ||
# [prefer tuples to lists! (intermediate)](https://youtu.be/8nvfOjvOF5w) | ||
|
||
Today I talk about the three reasons why I prefer tuples over lists! | ||
|
||
## Interactive examples | ||
|
||
### Python | ||
|
||
```python | ||
lst = [] | ||
tup = () | ||
|
||
import sys | ||
|
||
sys.getsizeof(lst) | ||
sys.getsizeof(tup) | ||
|
||
sys.getsizeof([1, 2, 3]) | ||
sys.getsizeof((1, 2, 3)) | ||
|
||
import dis | ||
|
||
def f(): | ||
x = (1, 2, 3) | ||
return x[1] | ||
|
||
|
||
def g(): | ||
x = [1, 2, 3] | ||
return x[1] | ||
|
||
|
||
dis.dis(g) | ||
dis.dis(f) | ||
|
||
import subprocess | ||
subprocess.check_call(['echo', 'hello hello world']) | ||
subprocess.check_call(('echo', 'hello hello world')) | ||
``` | ||
|
||
### Bash | ||
|
||
```bash | ||
python3 | ||
``` |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,16 @@ | ||
# [git: inline diffs with --word-diff! (intermediate)](https://youtu.be/Wn3bJUzvy5I) | ||
|
||
Today I show a tiny tip when working with patches in `git` (such as with `git diff` or `git log -p`) to show inline differences instead of full line differences | ||
|
||
## Interactive examples | ||
|
||
### Bash | ||
|
||
```bash | ||
git log --format= -p devenv/config.ini | ||
git log --word-diff --format= -p devenv/config.ini | ||
|
||
git log --word-diff-regex '[^[:space:]]' --word-diff --format= -p devenv/config.ini | ||
git log --word-diff-regex '[a-f0-9]+|[^[:space:]]' --word-diff --format= -p devenv/config.ini | ||
git log --word-diff-regex '[0-9]+|[a-f0-9]+|[^[:space:]]' --word-diff --format= -p devenv/config.ini | ||
``` |