• Kirill Smelkov's avatar
    gpython: Implement -O · 8564dfdd
    Kirill Smelkov authored
    Let's teach gpython and pymain about -O because buildout calls `python -O`
    to byte-compile python sources in optimized mode:
    
    nexedi/slapos!862 (comment 121470)
    
    When seeing -O, we take the approach to reexecute underlying python with
    -O, so that e.g.
    
    	gpython -O file.py
    
    becomes executed as
    
    	python -O gpython file.py
    
    This ensures correctness. The same approach could be used to implement
    support for e.g. -S and other low-level options.
    
    An earlier attempt to implement -O without reexecution can be seen at
    
    nexedi/pygolang!7
    
    together with list of problems that arise via that way.
    
    Original idea to reexecute itself come from @jerome.
    8564dfdd
gpython_test.py 11.7 KB