[Python-ideas] Python-ideas Digest, Vol 90, Issue 30
Ned Batchelder
ned at nedbatchelder.com
Thu May 22 00:54:13 CEST 2014
On 5/21/14 6:47 PM, Paul Moore wrote:
> On 21 May 2014 23:30, Trip Volpe <trip at flowroute.com> wrote:
>> On Wed, May 21, 2014 at 2:14 PM, Nathaniel Smith <njs at pobox.com> wrote:
>>> Isn't the real problem here that the peephole optimizer violates the
>>> first rule of optimization ("don't change semantics") by breaking
>>> sys.settrace? Couldn't we fix this directly?
>> I agree with this. Adding a command line flag to tinker with code generation
>> may well be opening a can of worms, but "the peephole optimizer shouldn't
>> change semantics" is a more compelling argument, although fixing it from
>> that angle is obviously more involved. One problem is that functions like
>> settrace() expose low-level details to the higher-level semantics. It's a
>> fair question as to whether it should be considered kosher to expose
>> implementation details like the peephole optimizer through such interfaces.
> While I'm happy to be proved wrong with code, my instinct is that
> "making sys.settrace work" would likely be too complex to be
> practical.
I absolutely agree that "fixing settrace" is likely to be 100x more
complex than disabling the optimizer.
>
> In any case, as you say, it exposes low-level details, and I would
> personally consider "glitches" like this as implementation details.
I also agree that the exact lines reported by settrace are to some
extent an implementation detail. All I'm asking for is a way to make
the implementation match the expectations.
> To
> put it another way, I don't consider the exact lines traced by
> sys.settrace to be part of the semantics of a program, any more than I
> consider the output of dis.dis to be. So in my view it is acceptable
> for the optimiser to change the lines that get traced in the way that
> coverage experienced.
>
> Paul.
> _______________________________________________
> Python-ideas mailing list
> Python-ideas at python.org
> https://mail.python.org/mailman/listinfo/python-ideas
> Code of Conduct: http://python.org/psf/codeofconduct/
More information about the Python-ideas
mailing list