I am pretty sure this is a backwards incompatible change. It isn't likely
syntax, but I think it is possible.
I also don't like having to wait until the end of the expression to find
out it isn't a list. And also seems like it would be easy to miss in a
non-trivial case.
How would you be parsed?
a = [1, 2, 3;
4, 5, 6]
On Fri, Nov 8, 2019, 09:13 <[email protected]> wrote:
> In recent years, python has become very popular due to the rise of data
> science and machine learning. This is mainly because Python is easy to
> learn and has a large number of third-party libraries, thus accumulating a
> large number of users.
> When Python is applied to scientific computing, there are two
> problems. One is that Python itself is not fast enough, and the other is
> that matrix is not a basic data type. The first problem can be well solved
> by rewriting key codes in C/C++, or by using numba. For the second one,
> people have invented Numpy which has become the actual matrix computing
> standard in Python. Although it can do linear algebra, limited by the
> syntax of Python, using Numpy to initialize a matrix is always not simple
> enough. We have to do it like this:
> import numpy as np
> a=np.array([1,2,3])
> b=np.array([[1,2,3],[4,5,6]])
> While, you know, in Matlab and Julia(A new ambitious and interesting
> language) it is in this way:
> a=[1,2,3] or a=[1 2 3]
> b=[1,2,3;4,5,6] or b=[1 2 3;4 5 6]
>
> Of course, python, as a general-purpose language, is not limited to
> scientific computing, but also used for crawlers, web development, and even
> writing GUI programs. Therefore, many developers do not need matrix
> operations, nor need to use numpy as a standard library.
> Since numpy has become the cornerstone of Python scientific
> computing, there is no need to reinvent another wheel, that is, to design
> new matrix data types. I suggest adding some parsing rules to the List data
> type to facilitate the initialization of a matrix.
>
> (1) Keeping the original syntax of List unchanged,for example:
> a = [1,2,3] # will be parsed to a normal list.
> b = [[1,2,3],[4,5,6]] # will be parsed to a normal list,too.
> Simply put, all the original list syntax remains unchanged.
> (2) Using semicolons as a flag to make a better integration of a List-like
> data type and Numpy. The Python interpreter will check whether the numpy
> library is installed. If not, it will stop running and remind the user to
> install it. The expected syntax:
> c = [1,2,3;] or c = [1 2 3;] or c = [1 2 3]
> Notice the semicolon after the last number. If numpy is found, c
> will be parsed as a Numpy ndarray. All these forms are equivelent to c =
> np.array([1,2,3]). For a vector, the semicolon is the key for Python to
> parse it as a Numpy ndarray.
>
> d=[1,2,3;4,5,6] or d=[1,2,3;4,5,6;] or d=[1 2 3;4 5 6] or d=[1 2
> 3;4 5 6;]
> Notice the semicolons. If numpy is found, d will be parsed as a
> Numpy ndarray. All these forms are equivelent to
> d=np.array([[1,2,3],[4,5,6]])
> You see,for defining a matrix or a vector,it will be nearly as
> simple as Matalab or Julia!
> Thank you!
> _______________________________________________
> Python-ideas mailing list -- [email protected]
> To unsubscribe send an email to [email protected]
> https://mail.python.org/mailman3/lists/python-ideas.python.org/
> Message archived at
> https://mail.python.org/archives/list/[email protected]/message/MGMU6TMPBP7HKIA2TAQI4QG4KCSEQVVQ/
> Code of Conduct: http://python.org/psf/codeofconduct/
>
_______________________________________________
Python-ideas mailing list -- [email protected]
To unsubscribe send an email to [email protected]
https://mail.python.org/mailman3/lists/python-ideas.python.org/
Message archived at
https://mail.python.org/archives/list/[email protected]/message/DB65OI7MC6YHY7QBJ2A4VSBDR2VMBDPT/
Code of Conduct: http://python.org/psf/codeofconduct/