GoCRustedPython (@GoCRustedPython) profile picture
Joined January 2024
#LazyEvaluation #Python 9: Once you are done with Generators you should close it.
1
1
18
#LazyEvaluation #Python 9: When working with lage data, we can chain generators together to create pipeline, each generator in the pipeline takes input from the previous generator, processes it, and passes it along to the next generator. This is a powerful construct in Python.
15
#LazyEvaluation #Python 8: Typing also support generators by having Generator type.
11
#LazyEvaluation #Python 6: Generators can also be used to generate infinite sequences. See #code #snippet below: Guess the output here, just remember yield will save the context before returning so variables will also be saved.
2
21
#LazyEvaluation #Python 5: Have you seen in last #codesnippet that you can use these Generators in comprehensions also ?
6
#LazyEvaluation #Python 4: So let's see how much memory benefit we get by using lazy evaluation in Python. Here we are creating normal and lazy objects and then printing their size.
12
#LazyEvaluation #Python 3: You can get values now, but there is a traceback right ? Exception is generated named StopIteration. So the object (created by using yield, called generator) generates a StopIteration exception when exhausted. So this can directly be used loops..
11
#LazyEvaluation #Python 2: Last #codesnippet has printed result as #Python generator object. So we can say Generators use yield to generate values lazily. To get real value we can use next() as in below snippet.
12
#LazyEvaluation #Python 1: yield keyword - suspends function execution by saving all the states and yield (return) to caller. Later resumes when called again, producing a series of values. Lets see with this #Snippet and guess the output ..
18
Let's explore lazy evaluation in Python. exprs upfront, storing them in memory to be used as needed. This approach leads to higher memory usage, which can be avoided by using lazy evaluation which produces values sequentially as needed. Let's learn how to do lazy evaluation in 🐍
1
22
In #Python understanding else under for loop is little tricky, below #code tries to explain it.
25
What below #python program does ? there is one problem with this code, can you identify and suggest fix ? #pythonprogramming
1
40
In continuation to earlier #Python program, what behaviour difference than that you can observe here ?
1
30
Lets have some warmup using #Python. In #pythonprogramming some very useful concepts are used which are showed in below #codesnippet. Can you identify few of them ?
1
1
26
Again a very minute change in earlier #Csnippet. Do you think it will change program behaviour as compared to last post #code ?
1
8
Similar #Csnippet I had posted earlier, this is little different from that, does this change help the code to run properly ?
1
1
14
Can you help solving this puzzle in #Cprogramming ? you will learn some very good concept while solving this.
1
1
15
Lets have a #Csnippet today :), Below snippet teaches two important concepts in #Clanguage. Can you guess the output on screen first ?
7
1
16