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

2023-02-05 Thread cdp49
> 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 -- [email protected]
To unsubscribe send an email to [email protected]
https://mail.python.org/mailman3/lists/python-dev.python.org/
Message archived at 
https://mail.python.org/archives/list/[email protected]/message/RWSSY4KZLQYXHFF34AR544C44NZ6K7XE/
Code of Conduct: http://python.org/psf/codeofconduct/


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

2023-02-05 Thread Joshua Herman
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, [email protected] 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 -- [email protected]
> To unsubscribe send an email to [email protected]
> https://mail.python.org/mailman3/lists/python-dev.python.org/
> Message archived at 
> https://mail.python.org/archives/list/[email protected]/message/RWSSY4KZLQYXHFF34AR544C44NZ6K7XE/
> Code of Conduct: http://python.org/psf/codeofconduct/
___
Python-Dev mailing list -- [email protected]
To unsubscribe send an email to [email protected]
https://mail.python.org/mailman3/lists/python-dev.python.org/
Message archived at 
https://mail.python.org/archives/list/[email protected]/message/HT4NRQ7BYJLUGRQ33HOI45QBG4EC2PIO/
Code of Conduct: http://python.org/psf/codeofconduct/