If the value of any expression is not used, and the expression has no side-effects, then it is deleted. As with constant folding, this optimization applies most often when cleaning up after inline expansion and other optimizations. Any function declared anextensions:constant-function is also subject to unused expression elimination.
Note that Python will eliminate parts of unused expressions known to be side-effect free, even if there are other unknown parts. For example: