When using python to compile to bytecode, it is really inconvenient that the compiler is fixed into using whatever opmiziation level the interpreter was started with. This makes it impossible to create e.g. .zip libraries of different optimization levels from a single python session. What is more, a program that creates optimized .zip files cannot itself have active asserts and so on. Adding the optimize state to the compiler´s state outht not to be too difficult. We could then: compile(source, filename, mode[, flags[, dont_inherit[, optimize]]]) with optmize defaulting to the interpreter's current level. Same with py_compile, and so on. K
Kristján Valur Jónsson wrote:
When using python to compile to bytecode, it is really inconvenient that the compiler is fixed into using whatever opmiziation level the interpreter was started with. This makes it impossible to create e.g. .zip libraries of different optimization levels from a single python session. What is more, a program that creates optimized .zip files cannot itself have active asserts and so on. Adding the optimize state to the compiler´s state outht not to be too difficult. We could then: compile(source, filename, mode[, flags[, dont_inherit[, optimize]]]) with optmize defaulting to the interpreter's current level.
Same with py_compile, and so on.
+1 We could then remove the tricks in distutils to compile a package using an external spawned Python process to get around the limitation. See e.g. mxTools for an alternative, but not thread-safe approach: http://www.egenix.com/products/python/mxBase/mxTools/doc/#_Toc199521822 mx.Tools.optimization([level]) -- Marc-Andre Lemburg eGenix.com Professional Python Services directly from the Source (#1, Nov 26 2010)
Python/Zope Consulting and Support ... http://www.egenix.com/ mxODBC.Zope.Database.Adapter ... http://zope.egenix.com/ mxODBC, mxDateTime, mxTextTools ... http://python.egenix.com/
::: Try our new mxODBC.Connect Python Database Interface for free ! :::: eGenix.com Software, Skills and Services GmbH Pastor-Loeh-Str.48 D-40764 Langenfeld, Germany. CEO Dipl.-Math. Marc-Andre Lemburg Registered at Amtsgericht Duesseldorf: HRB 46611 http://www.egenix.com/company/contact/
2010/11/26 M.-A. Lemburg
Kristján Valur Jónsson wrote:
When using python to compile to bytecode, it is really inconvenient that the compiler is fixed into using whatever opmiziation level the interpreter was started with. This makes it impossible to create e.g. .zip libraries of different optimization levels from a single python session. What is more, a program that creates optimized .zip files cannot itself have active asserts and so on. Adding the optimize state to the compiler´s state outht not to be too difficult. We could then: compile(source, filename, mode[, flags[, dont_inherit[, optimize]]]) with optmize defaulting to the interpreter's current level.
Same with py_compile, and so on.
+1
We could then remove the tricks in distutils to compile a package using an external spawned Python process to get around the limitation.
FWIW I'm +1 as well It would be nice getting rid of that spawning hack in our company's build process too. -- Debian GNU/Linux -- The Power of Freedom www.debian.org | www.gnu.org | www.kernel.org
Am 26.11.2010 23:54, schrieb Floris Bruynooghe:
2010/11/26 M.-A. Lemburg
: Kristján Valur Jónsson wrote:
When using python to compile to bytecode, it is really inconvenient that the compiler is fixed into using whatever opmiziation level the interpreter was started with. This makes it impossible to create e.g. .zip libraries of different optimization levels from a single python session. What is more, a program that creates optimized .zip files cannot itself have active asserts and so on. Adding the optimize state to the compiler´s state outht not to be too difficult. We could then: compile(source, filename, mode[, flags[, dont_inherit[, optimize]]]) with optmize defaulting to the interpreter's current level.
Same with py_compile, and so on.
+1
We could then remove the tricks in distutils to compile a package using an external spawned Python process to get around the limitation.
FWIW I'm +1 as well
It would be nice getting rid of that spawning hack in our company's build process too.
I've posted a patch at http://bugs.python.org/issue10553. Reviews are welcome. Georg
participants (4)
-
Floris Bruynooghe
-
Georg Brandl
-
Kristján Valur Jónsson
-
M.-A. Lemburg