2019-05-20 | Paul Boddie | raw files shortlog changelog graph | Demonstrate undesirable side-effects caused by escaping temporary objects. | temporary-object-experiment |
tests/temp_side_effects.py (file) |
1.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000 1.2 +++ b/tests/temp_side_effects.py Mon May 20 16:49:05 2019 +0200 1.3 @@ -0,0 +1,12 @@ 1.4 +def f(x): 1.5 + x + 10 1.6 + return x 1.7 + 1.8 +a = 1.0 1.9 +b = 2.0 1.10 +c = 3.0 1.11 +d = f(a * b) 1.12 + 1.13 +print a * b + c # 5.0 1.14 +print d + c # 5.0 1.15 +print d # 2.0