On 14 November 2016 at 00:08, Todd <toddr...@gmail.com> wrote: > > On Sun, Nov 13, 2016 at 4:00 PM, Mikhail V <mikhail...@gmail.com> wrote: >> >> On 12 November 2016 at 21:08, João Matos <jcrma...@gmail.com> wrote: >> >> > What I would like to propose is the creation of the reverse: >> > a =+ c is the same as a = c + a >> > a =- c is the same as a = c - a >> > a =* c is the same as a = c * a >> > a =/ c is the same as a = c / a >> > a =// c is the same as a = c // a >> > a =% c is the same as a = c % a >> > a =** c is the same as a = c ** a >> >> A good syntax example: >> >> a = sum (a, c) >> a = mul (a, c) >> a = div (a, c) > > > Except that there is no "div" in python 3.x, and "sum(a, c)" does not add > "a" and "c". > >> >> Another good syntax, I'm not a fan of, but at least intuitive and >> learnt in school: >> >> a = a + c >> a = a * c >> a = a / c > > > How is using a function better than using an operator? Especially > considering the ambiguity issues you just demonstrated. > > The fact the operator version is part of the core language while the > function versions aren't even builtins (they are in the "operator" module) > suggests to me that the function version is not the preferred version in > Python. > >> >> Bad syntax, not readable: >> >> a += c >> a -= c >> a *= c >> > > What, specifically, is not readable about this syntax? > >> >> As for me, I would even prohibit all these += for the sake of >> readability. > > > Great, so I will have to make a copy of my 500 MB array every time I want to > do a simple mathematical operation on it rather than being able to do the > operation in-place.
It is kind of clear from the context, that I am speaking of syntax and not how things are working under the hood, or? If a compiler cannot optimize "a = a + 1" into an in-place operation, that is misfortune. In numpy one can define in-place calulations, if I am not mistaken, with np.vectorize. A better option would be to support unary operators so the user can write directly without assignment: inc (a, 1) Would mean in-place increment "a" with 1 >> a += c >> a -= c >> a *= c >> > > What, specifically, is not readable about this syntax? Well, if you find this syntax readable, then I am afraid we are on the opposite sides of barricades ;) Mikhail _______________________________________________ Python-ideas mailing list Python-ideas@python.org https://mail.python.org/mailman/listinfo/python-ideas Code of Conduct: http://python.org/psf/codeofconduct/