by eesmith · 5y ago · 0 comments
At the very least, I can't reproduce it.
% cat tmp.py
(1<<19**8,)*4**7
% python -m compileall tmp.py
% ls -l __pycache__/tmp.cpython-39.pyc
-rw-r--r-- 1 eesmith admin 167 Feb 16 12:21 __pycache__/tmp.cpython-39.pyc
Python 3.6 generates a 144 byte file. One of the comments says it caused a problem in Python 3.3.5.Another peephole optimizer gotcha that caused problems with older Pythons is at https://bugs.python.org/issue30416 :
def tuple20():
return ((((((((1,)*20,)*20,)*20,)*20,)*20,)*20,)*20,)*20
If you have Python 2.7 hanging about, try simply defining that function - you can't even ^C it!It doesn't explode in size.
The peephole optimizer is checking for uniqueness, via a dict, and evaluating hash() of that constant takes a very long time.