
A Python Puzzle (2013) - luu
http://akaptur.com/blog/2013/10/29/a-python-puzzle/
======
eesmith
One of the undocumented oddities of the peephole optimizer is that it will try
to merge duplicate constants. When combined with integer (non-)interning, this
lets me do:

    
    
      >>> a = 300
      >>> b = 300
      >>> print(a is b)
      False
      >>> a = 300; b = 300; print(a is b)
      True
      >>> def my_function():
      ...   a = 300
      ...   b = 300
      ...   print(a is b)
      ...
      >>> my_function()
      True
    

... and I see in the followup posting (this puzzle is from 213) that that was
the desired answer, and that it was further analyzed in various ways, and
improved upon.

~~~
AstralStorm
Pretty cool. I was thinking about some scoping issue. (Python scoping is very
crusty.)

