[Python-Dev] Re: PEP 638: Syntactic macros

2023-02-02 Thread Stéfane Fermigier
On Thu, Feb 2, 2023 at 8:34 AM Stephen J. Turnbull <
stephenjturnb...@gmail.com> wrote:

> cd...@cam.ac.uk writes:
>
>  > I don't want to be forced to learn lots of weird little functions
>  > like `np.matmul(x1, x2)` when there's already one obvious syntax
>  > I'm very familiar with: `x1 * x2`.
>
> I don't recall ever writing matrix multiplication that way in
> mathematics though.  That's universally written as juxtaposition in my
> experience.  And the obvious way to write it in Python (and np) has
> been "x1 @ x2" for some years now.  In np, "*" means element-wise
> multiplication, I believe.
>

My 2 cents as a former mathematician:

Mathematicians have come up with hundreds of symbols to express the variety
of structures they are dealing with.

Just to list a few:

https://en.wikipedia.org/wiki/Mathematical_operators_and_symbols_in_Unicode
https://oeis.org/wiki/List_of_LaTeX_mathematical_symbols

So +, *, -, /, @ and ** are a good start to express the most common
mathematical structures (groups, rings, vector spaces), and <, >, <=, >=,
==, != for ordered sets, but that's it.

It's great that Python supports overloading these operations. That's
something that drew me to Python when I was still working in computational
number theory, 25 years ago.

But that's probably not enough for some people. A way to add new symbols
(including non-ascii Unicode characters) and operations could have some
value, but also the drawback of tremendous additional complexity, specially
if done in the most generic way.

NB: on a very basic level, I remember trying, a few years ago, to use the
Unicode "empty set" symbol as a synonym for set(), and it didn't end well,
for several reasons, including the fact that Python didn't like it as a
variable name.

  S.

-- 
Stefane Fermigier - http://fermigier.com/ - http://twitter.com/sfermigier -
http://linkedin.com/in/sfermigier
Founder & CEO, Abilian - Enterprise Social Software -
http://www.abilian.com/
Co-Founder & Co-Chairman, National Council for Free & Open Source Software
(CNLL) - http://cnll.fr/
Co-Founder & Chairman, Association Professionnelle Européenne du Logiciel
Libre (APELL) - https://www.apell.info/
Co-Founder & Spokesperson, European Cloud Industrial Alliance (EUCLIDIA) -
https://www.euclidia.eu/

"I wish you were as accurate, & as much to be relied on, as I am myself" -
Lady Ada Lovelace
___
Python-Dev mailing list -- python-dev@python.org
To unsubscribe send an email to python-dev-le...@python.org
https://mail.python.org/mailman3/lists/python-dev.python.org/
Message archived at 
https://mail.python.org/archives/list/python-dev@python.org/message/G2XSNXZSTPCDUDIUFHURGIBQ4HO7SG5B/
Code of Conduct: http://python.org/psf/codeofconduct/


[Python-Dev] Re: PEP 638: Syntactic macros

2023-02-02 Thread David Mertz, Ph.D.
On Thu, Feb 2, 2023 at 12:46 PM Stéfane Fermigier  wrote:

> https://en.wikipedia.org/wiki/Mathematical_operators_and_symbols_in_Unicode
> https://oeis.org/wiki/List_of_LaTeX_mathematical_symbols
> NB: on a very basic level, I remember trying, a few years ago, to use the
> Unicode "empty set" symbol as a synonym for set(), and it didn't end well,
> for several reasons, including the fact that Python didn't like it as a
> variable name.
>

I use the `vim` conceal plugin to make some of these appear on screen while
I'm editing. So, for example, when I type `set()` I see `∅`.  When I type
`all(...)` I see `∀(...)`.

Much to the chagrin of Moshe Zadka, when I type `None` I see `ℵ` ...
because I argue that ℵ_0 really should be considered an inaccessible
cardinal :-).

However, it never causes me problems because the files on disk are just
plain old ASCII (for the most part), and the special symbols are just what
my screen shows, not overloads to underlying operators.

-- 
The dead increasingly dominate and strangle both the living and the
not-yet born.  Vampiric capital and undead corporate persons abuse
the lives and control the thoughts of homo faber. Ideas, once born,
become abortifacients against new conceptions.
___
Python-Dev mailing list -- python-dev@python.org
To unsubscribe send an email to python-dev-le...@python.org
https://mail.python.org/mailman3/lists/python-dev.python.org/
Message archived at 
https://mail.python.org/archives/list/python-dev@python.org/message/3BFWMNHH5VMVROWNKH77ORZL2ECDPP7C/
Code of Conduct: http://python.org/psf/codeofconduct/