Movatterモバイル変換


[0]ホーム

URL:


homepage

Issue21176

This issue trackerhas been migrated toGitHub, and is currentlyread-only.
For more information, see the GitHub FAQs in the Python's Developer Guide.

classification
Title:Implement matrix multiplication operator (PEP 465)
Type:enhancementStage:resolved
Components:Interpreter CoreVersions:Python 3.5
process
Status:closedResolution:fixed
Dependencies:Superseder:
Assigned To: benjamin.petersonNosy List: belopolsky, benjamin.peterson, jcea, njs, python-dev
Priority:normalKeywords:patch

Created on2014-04-08 02:51 bybelopolsky, last changed2022-04-11 14:58 byadmin. This issue is nowclosed.

Files
File nameUploadedDescriptionEdit
mat-mult1.patchbenjamin.peterson,2014-04-08 04:31review
mat-mult2.patchbenjamin.peterson,2014-04-08 04:41review
mat-mult3.patchbenjamin.peterson,2014-04-08 05:01review
mat-mult4.patchbenjamin.peterson,2014-04-08 05:26review
mat-mult5.patchbenjamin.peterson,2014-04-08 14:42review
Messages (15)
msg215724 -(view)Author: Alexander Belopolsky (belopolsky)*(Python committer)Date: 2014-04-08 02:51
[Nathaniel Smith at numpy-discussion]Guido just formally acceptedPEP 465:https://mail.python.org/pipermail/python-dev/2014-April/133819.htmlhttp://legacy.python.org/dev/peps/pep-0465/#implementation-detailsYay.The next step is to implement it, in CPython and in numpy. I have timeto advise on this, but not to do it myself, so, any volunteers? Everwanted to hack on the interpreter itself, with BDFL guarantee yourpatch will be accepted (if correct)?The todo list for CPython is here:http://legacy.python.org/dev/peps/pep-0465/#implementation-detailsThere's one open question which is where the type slots should beadded. I'd just add them to PyNumberMethods and then if someoneobjects during patch review it can be changed.
msg215726 -(view)Author: Benjamin Peterson (benjamin.peterson)*(Python committer)Date: 2014-04-08 04:31
Here's a first patch. It works, but needs more tests (associativity, precedence, __rmatmul__, etc...) and also docs. I can work on that tomorrow.
msg215730 -(view)Author: Benjamin Peterson (benjamin.peterson)*(Python committer)Date: 2014-04-08 04:41
Here are changes to the operator module...
msg215731 -(view)Author: Alexander Belopolsky (belopolsky)*(Python committer)Date: 2014-04-08 04:57
I've got to the point where I can do>>> import ast>>> ast.dump(ast.parse('a @ b'))"Module(body=[Expr(value=BinOp(left=Name(id='a', ctx=Load()), op=MatMult(), right=Name(id='b', ctx=Load())))])"I'll post a link to my bitbucket clone shortly.
msg215732 -(view)Author: Benjamin Peterson (benjamin.peterson)*(Python committer)Date: 2014-04-08 05:01
Here is a nearly complete patch...
msg215734 -(view)Author: Alexander Belopolsky (belopolsky)*(Python committer)Date: 2014-04-08 05:09
Wow! That was quick. And I am still fighting with bitbucket.  Maybe I should stop duplicating the effort at this point.
msg215735 -(view)Author: Benjamin Peterson (benjamin.peterson)*(Python committer)Date: 2014-04-08 05:14
On Mon, Apr 7, 2014, at 22:09, Alexander Belopolsky wrote:> > Alexander Belopolsky added the comment:> > Wow! That was quick. And I am still fighting with bitbucket.  Maybe I> should stop duplicating the effort at this point.Sorry about that. I only saw the first message, where Nathaniel invitesan implementation. I didn't realize that was a direct quote from themailing list (not by you) and didn't notice you also assigned it toyourself.
msg215736 -(view)Author: Alexander Belopolsky (belopolsky)*(Python committer)Date: 2014-04-08 05:23
Thanks for stepping in.  From a quick look at your patch I don't see anything that I would do much differently.I noticed some whitespace issues inInclude/token.h:-#define AT              49-#define RARROW          50-#define ELLIPSIS        51+#define AT              49+#define ATEQUAL50+#define RARROW          51+#define ELLIPSIS        52(Are you sure you want to re-enumerate RARROW and ELLIPSIS? Why not just give ATEQUAL the value of 52?)
msg215737 -(view)Author: Alexander Belopolsky (belopolsky)*(Python committer)Date: 2014-04-08 05:25
+   .. versionadded:: 3.4Are you planning to use the time machine? :-)
msg215738 -(view)Author: Benjamin Peterson (benjamin.peterson)*(Python committer)Date: 2014-04-08 05:25
On Mon, Apr 7, 2014, at 22:23, Alexander Belopolsky wrote:> > Alexander Belopolsky added the comment:> > Thanks for stepping in.  From a quick look at your patch I don't see> anything that I would do much differently.> > I noticed some whitespace issues inInclude/token.h:> > -#define AT              49     > -#define RARROW          50> -#define ELLIPSIS        51> +#define AT              49> +#define ATEQUAL                50> +#define RARROW          51> +#define ELLIPSIS        52> > (Are you sure you want to re-enumerate RARROW and ELLIPSIS? Why not just> give ATEQUAL the value of 52?)I thought it would be nicer if ATEQUAL was right after AT.
msg215739 -(view)Author: Benjamin Peterson (benjamin.peterson)*(Python committer)Date: 2014-04-08 05:25
On Mon, Apr 7, 2014, at 22:25, Alexander Belopolsky wrote:> > Alexander Belopolsky added the comment:> > +   .. versionadded:: 3.4> > Are you planning to use the time machine? :-)Good catch. :)
msg215740 -(view)Author: Benjamin Peterson (benjamin.peterson)*(Python committer)Date: 2014-04-08 05:26
Here's my latest and greatest version. I'll finish up after some sleep.
msg215762 -(view)Author: Benjamin Peterson (benjamin.peterson)*(Python committer)Date: 2014-04-08 14:42
Here's what I consider a complete patch.
msg215863 -(view)Author: Benjamin Peterson (benjamin.peterson)*(Python committer)Date: 2014-04-10 03:53
I think this patch is fairly straightforward, and I don't want it to rot, so here we go...
msg215865 -(view)Author: Roundup Robot (python-dev)(Python triager)Date: 2014-04-10 03:56
New changesetc553d8f72d65 by Benjamin Peterson in branch 'default':PEP 465: a dedicated infix operator for matrix multiplication (closes#21176)http://hg.python.org/cpython/rev/c553d8f72d65
History
DateUserActionArgs
2022-04-11 14:58:01adminsetgithub: 65375
2014-06-12 00:57:19jceasetnosy: +jcea
2014-04-10 03:56:05python-devsetstatus: open -> closed

nosy: +python-dev
messages: +msg215865

resolution: fixed
stage: needs patch -> resolved
2014-04-10 03:53:14benjamin.petersonsetmessages: +msg215863
2014-04-09 12:55:14njssetnosy: +njs
2014-04-08 14:42:13benjamin.petersonsetfiles: +mat-mult5.patch
assignee:belopolsky ->benjamin.peterson
messages: +msg215762
2014-04-08 05:26:55benjamin.petersonsetfiles: +mat-mult4.patch

messages: +msg215740
2014-04-08 05:25:52benjamin.petersonsetmessages: +msg215739
2014-04-08 05:25:32benjamin.petersonsetmessages: +msg215738
2014-04-08 05:25:30belopolskysetmessages: +msg215737
2014-04-08 05:23:04belopolskysetmessages: +msg215736
2014-04-08 05:14:42benjamin.petersonsetmessages: +msg215735
2014-04-08 05:09:26belopolskysetmessages: +msg215734
2014-04-08 05:01:24benjamin.petersonsetfiles: +mat-mult3.patch

messages: +msg215732
2014-04-08 04:57:24belopolskysetmessages: +msg215731
2014-04-08 04:41:21benjamin.petersonsetfiles: +mat-mult2.patch

messages: +msg215730
2014-04-08 04:32:03benjamin.petersonsetfiles: +mat-mult1.patch

nosy: +benjamin.peterson
messages: +msg215726

keywords: +patch
2014-04-08 02:51:34belopolskycreate
Supported byThe Python Software Foundation,
Powered byRoundup
Copyright © 1990-2022,Python Software Foundation
Legal Statements

[8]ページ先頭

©2009-2026 Movatter.jp