[Python-ideas] PEP 511: API for code transformers

Victor Stinner victor.stinner at gmail.com
Thu Jan 28 12:03:58 EST 2016


2016-01-28 17:57 GMT+01:00 Sven R. Kunze <srkunze at mail.de>:
> I suspected that. So, where is this place of "before the first" import?

I don't understand your question.

I guess that your real question is: are stdlib modules loaded with
peephole optimizer enabled or not?

If you use -o noopt, you are safe: the peephole optimizer is disabled
before the first Python import.

If you use sys.set_code_transformers([]) in your code, it's likely
that Python already imported 20 or 40 modules during its
initialization (especially in the site module).

It's up to you to pick the best option. There are different usages for
each option. Maybe you just don't care of the stdlib, you only want to
debug your application code, so it's doesn't matter how the stlidb is
optimized?

--

Or are you asking me to remove sys.set_code_transformers([]) from the
section "Usage 3: Disable all optimization"? I don't understand.


Victor


More information about the Python-ideas mailing list