Mailing List Archive

1 2  View All
Re: PEP 638: Syntactic macros [ In reply to ]
The easiest and straightforward way to help python would be taking the mantle of implementing PEP 638 or restarting the development of a library for syntactic macros since you believe it will be a benefit to Python in general.

Sent from my iPhone

> On Feb 5, 2023, at 3:58 PM, cdp49@cam.ac.uk wrote:
>
> ?
>>
>> Python has consistently refused to be turned into a platform for DSLs for almost 3 decades.
>
> I think SymPy, PyMC, Pyomo, Pyro, and many more packages would all be very surprised to hear they're no longer welcome in Python. Still, it seems like it would be quite hard to kick them out, and would probably make the scientific programming community pretty angry. If you don't like having DSLs in Python, I think you're trying to close the barn door after the horse has bolted; you'd have to go back in time to the creation of NumPy.
>
> Syntactic macros aren't necessary for DSLs; it just makes them better. Without syntactic macros, DSLs are forced to use clunky, complicated, and error-prone string manipulation, rather than cleaner syntactic transformations. For instance, here's NumPy's einsum, effectively behaving like a string macro:
> ```
> X = np.einsum('ij,jk->ik', A, B, optimize='optimal')
> ```
>
> And now here's the same thing in Julia:
> ```
> @einsum X[i, k] := A[i, j] * B[j, k]
> ```
>
> Which is more readable? Which is more Pythonic?
>
> It's not that Python doesn't have DSLs (NumPy is effectively a DSL for linear algebra). It's just that their syntax is sufficiently obscure that it's not at all clear that's what they're doing.
> _______________________________________________
> Python-Dev mailing list -- python-dev@python.org
> To unsubscribe send an email to python-dev-leave@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/RWSSY4KZLQYXHFF34AR544C44NZ6K7XE/
> Code of Conduct: http://python.org/psf/codeofconduct/
_______________________________________________
Python-Dev mailing list -- python-dev@python.org
To unsubscribe send an email to python-dev-leave@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/HT4NRQ7BYJLUGRQ33HOI45QBG4EC2PIO/
Code of Conduct: http://python.org/psf/codeofconduct/

1 2  View All