I was going to say that such a matrix module would be better of in PyPI, but then I recalled how the statistics module got created, and I think that the same reasoning from PEP 450 applies here too ( https://www.python.org/dev/peps/pep-0450/#rationale). So I'd say go for it! I think it would even be okay to deviate from the numpy.matrix API (though not needlessly).
On Thu, Aug 13, 2020 at 6:20 PM Steven D'Aprano <st...@pearwood.info> wrote: > On Thu, Aug 13, 2020 at 11:17:00PM +0100, Stefano Borini wrote: > > > The math module has plenty of mathematical functions that are very > > interesting, but no Matrix object. > > Funny you mention this, I have been working on a Matrix object for > precisely the use-case you discuss (secondary school maths), where > performance is not critical and the dimensions of the matrix is > typically single digits. > > I, um, got distracted with some over-engineering and then distracted > further by work and life, but perhaps this is a good opportunity for me > to get it back on track. > > > > Generally, when a Matrix object is needed, numpy is the point of > > reference, but numpy requires understanding pip, installing modules, > > maybe creating a virtual environment and finally understanding numpy. > > And numpy also offers a surprising interface that doesn't match > matrices. (Well, surprising to those who aren't heavy users of numpy :-) > > py> A = numpy.array([[1, 2], [3, 4]]) > py> A*A > array([[ 1, 4], > [ 9, 16]]) > > To get *matrix multiplication* you have to use the `@` multiplication > operator from PEP 465: > > py> A@A > array([[ 7, 10], > [15, 22]]) > > https://www.python.org/dev/peps/pep-0465/ > > But what's really surprising about numpy arrays is broadcasting: > > py> A = numpy.array([[1, 2], [3, 4]]) > py> B = numpy.array([[10, 20]]) > py> A + B > array([[11, 22], > [13, 24]]) > > I don't know if broadcasting is actually useful or not, but > it's not what you want when doing matrix arithmetic at a > secondary school level. > > > -- > Steven > _______________________________________________ > Python-ideas mailing list -- python-ideas@python.org > To unsubscribe send an email to python-ideas-le...@python.org > https://mail.python.org/mailman3/lists/python-ideas.python.org/ > Message archived at > https://mail.python.org/archives/list/python-ideas@python.org/message/FARJRNHNLNGRVJA3ITSUSAJCXOUUYKA2/ > Code of Conduct: http://python.org/psf/codeofconduct/ > -- --Guido van Rossum (python.org/~guido) *Pronouns: he/him **(why is my pronoun here?)* <http://feministing.com/2015/02/03/how-using-they-as-a-singular-pronoun-can-change-the-world/>
_______________________________________________ Python-ideas mailing list -- python-ideas@python.org To unsubscribe send an email to python-ideas-le...@python.org https://mail.python.org/mailman3/lists/python-ideas.python.org/ Message archived at https://mail.python.org/archives/list/python-ideas@python.org/message/WJQHAPZBWLTSSLMB4KYX2UZEGBNUM6GO/ Code of Conduct: http://python.org/psf/codeofconduct/