Skip to content

Commit

Permalink
Added stuff about generators
Browse files Browse the repository at this point in the history
  • Loading branch information
mraza007 committed Dec 22, 2018
1 parent b3bd54a commit a645bee
Showing 1 changed file with 12 additions and 1 deletion.
13 changes: 12 additions & 1 deletion markdown-version/lambdas.md
Original file line number Diff line number Diff line change
Expand Up @@ -80,4 +80,15 @@ list = ['Casey','Charlie','Courtney','Cashmere']
x = [name[0] == 'C' for name in list]
print(all(x))
#This will return True since every name starts with C
```
```

Generator Expressions
- They are less memory consuming.
- Readmore on [List vs Generators](https://stackoverflow.com/questions/47789/generator-expressions-vs-list-comprehension)
- ```python
#A small test \
import sys
list_comp = [x for x in range(10)]
gen = (x for x in range(10))
print(f'The mem usage of a list {list_comp} and mem usage of gen {gen}')
```

0 comments on commit a645bee

Please sign in to comment.