On Wed, Aug 1, 2018 at 7:09 PM, Jonathan Fine <jfine2...@gmail.com> wrote: > Hi Chris > > We're discussing. >> 10) a ?. b ?. c >> 11) (a ?. b) ?. c > > I asked >> So, are there any values of 'a' for which #10 and #11 don't give the >> same result? > > You replied >> I'm not prepared to put my neck out and say "They are absolutely >> identical" and have people jump on me with some technicality. What is >> your point here? > > I am willing to put my neck out and say a.b.c and (a.b).c are > equivalent. And my understanding for PEP 505 is that #10 and #11 is > that they are equivalent.
The first pair are easily proven, since we can just probe existing code. >>> import dis >>> dis.dis(lambda a: a.b.c) 1 0 LOAD_FAST 0 (a) 2 LOAD_ATTR 0 (b) 4 LOAD_ATTR 1 (c) 6 RETURN_VALUE >>> dis.dis(lambda a: (a.b).c) 1 0 LOAD_FAST 0 (a) 2 LOAD_ATTR 0 (b) 4 LOAD_ATTR 1 (c) 6 RETURN_VALUE >>> Same byte code? Same result. Unless there's a bug in the peephole optimizer or something, which I doubt. ChrisA _______________________________________________ Python-ideas mailing list Python-ideas@python.org https://mail.python.org/mailman/listinfo/python-ideas Code of Conduct: http://python.org/psf/codeofconduct/