Issue 36669: weakref proxy doesn't support the matrix multiplication operator (original) (raw)

Created on 2019-04-19 14:08 by bup, last changed 2022-04-11 14:59 by admin. This issue is now closed.

Pull Requests
URL Status Linked Edit
PR 12932 merged mark.dickinson,2019-04-24 08:12
Messages (6)
msg340553 - (view) Author: SilentGhost (SilentGhost) * (Python triager) Date: 2019-04-19 17:29
It's not obvious why it should. Do you care to show a use case you had in mind?
msg340760 - (view) Author: Mark Dickinson (mark.dickinson) * (Python committer) Date: 2019-04-24 07:36
> It's not obvious why it should. I'd say that it's not obvious why it shouldn't. The "weakproxy" type currently supports every single "PyNumberMethods" slot *except* matrix multiplication: see https://github.com/python/cpython/blob/bf94cc7b496a379e1f604aa2e4080bb70ca4020e/Objects/weakrefobject.c#L610-L645 It seems likely that this was an unintentional omission when matrix multiplication was added. I can't think of any good reason to support all but one (well, two, including the in-place method) of those PyNumberMethods. Supporting all of them gives a (conceptually) smaller, simpler object. I think this is a consistency bug that should be fixed.
msg340763 - (view) Author: Mark Dickinson (mark.dickinson) * (Python committer) Date: 2019-04-24 08:35
Adding Nathaniel Smith (the matrix multiplication PEP author), just in case he knows some reason why weakref.proxy objects should _not_ support the matrix multiplication operator.
msg340767 - (view) Author: Nathaniel Smith (njs) * (Python committer) Date: 2019-04-24 10:22
Yeah, seems like a simple oversight to me. (Actually this is the first I've heard of weakref.proxy...)
msg340885 - (view) Author: Mark Dickinson (mark.dickinson) * (Python committer) Date: 2019-04-26 06:56
New changeset 7abb6c05afd02c17c7a941b64db5756b161b3cf7 by Mark Dickinson in branch 'master': bpo-36669: add matmul support to weakref.proxy (GH-12932) https://github.com/python/cpython/commit/7abb6c05afd02c17c7a941b64db5756b161b3cf7
msg340894 - (view) Author: Mark Dickinson (mark.dickinson) * (Python committer) Date: 2019-04-26 08:46
Now fixed for 3.8. Although this was an oversight, I'm erring on the side of regarding this as a new feature for 3.8 (and I think the omission is unlikely to bite anyone for Python 3.7 or 3.6), so I wouldn't recommend backporting this. Thanks for the report!
History
Date User Action Args
2022-04-11 14:59:14 admin set github: 80850
2019-04-26 08:46:22 mark.dickinson set status: open -> closedresolution: fixedmessages: + stage: patch review -> resolved
2019-04-26 06:56:19 mark.dickinson set messages: +
2019-04-24 10:22:02 njs set messages: +
2019-04-24 08:37:47 mark.dickinson set assignee: mark.dickinson
2019-04-24 08:35:18 mark.dickinson set nosy: + njsmessages: +
2019-04-24 08:12:37 mark.dickinson set keywords: + patchstage: patch reviewpull_requests: + <pull%5Frequest12857>
2019-04-24 07:36:28 mark.dickinson set status: pending -> opennosy: + mark.dickinsonmessages: +
2019-04-20 07:49:38 SilentGhost set status: open -> pending
2019-04-19 17:29:47 SilentGhost set versions: + Python 3.8nosy: + SilentGhost, fdrakemessages: + components: + Library (Lib)type: enhancement
2019-04-19 14:08:57 bup create