Skip to content

Instantly share code, notes, and snippets.

@charles2588
Created June 28, 2016 05:29
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
Star You must be signed in to star a gist
Save charles2588/90c74ce2e8a529895f3ae1a134574a1f to your computer and use it in GitHub Desktop.
https://repl.it/C6f4/1 created by charles2588
#Generator function yields iterator rather than returning value, no function calls or calls on stack thus saving memory
def f(n):
for x in range(n):
yield x**3
for i in f(5):
print(i)
Python 3.5.1 (default, Dec 2015, 13:05:11)
[GCC 4.8.2] on linux
0
1
8
27
64
=> None
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment