This issue tracker has been migrated to GitHub, and is currently read-only.
For more information, see the GitHub FAQs in the Python's Developer Guide.

classification
Title: weakref proxy doesn't support the matrix multiplication operator
Type: enhancement Stage: resolved
Components: Library (Lib) Versions: Python 3.8
process
Status: closed Resolution: fixed
Dependencies: Superseder:
Assigned To: mark.dickinson Nosy List: SilentGhost, bup, fdrake, mark.dickinson, njs
Priority: normal Keywords: patch

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:14adminsetgithub: 80850
2019-04-26 08:46:22mark.dickinsonsetstatus: open -> closed
resolution: fixed
messages: + msg340894

stage: patch review -> resolved
2019-04-26 06:56:19mark.dickinsonsetmessages: + msg340885
2019-04-24 10:22:02njssetmessages: + msg340767
2019-04-24 08:37:47mark.dickinsonsetassignee: mark.dickinson
2019-04-24 08:35:18mark.dickinsonsetnosy: + njs
messages: + msg340763
2019-04-24 08:12:37mark.dickinsonsetkeywords: + patch
stage: patch review
pull_requests: + pull_request12857
2019-04-24 07:36:28mark.dickinsonsetstatus: pending -> open
nosy: + mark.dickinson
messages: + msg340760

2019-04-20 07:49:38SilentGhostsetstatus: open -> pending
2019-04-19 17:29:47SilentGhostsetversions: + Python 3.8
nosy: + SilentGhost, fdrake

messages: + msg340553

components: + Library (Lib)
type: enhancement
2019-04-19 14:08:57bupcreate