You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
weakref proxy doesn't support the matrix multiplication operator #80850
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
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.
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.
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.
Activity
SilentGhost commentedon Apr 19, 2019
It's not obvious why it should. Do you care to show a use case you had in mind?
mdickinson commentedon Apr 24, 2019
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
cpython/Objects/weakrefobject.c
Lines 610 to 645 in bf94cc7
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.
mdickinson commentedon Apr 24, 2019
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.
njsmith commentedon Apr 24, 2019
Yeah, seems like a simple oversight to me. (Actually this is the first I've heard of weakref.proxy...)
mdickinson commentedon Apr 26, 2019
New changeset 7abb6c0 by Mark Dickinson in branch 'master':
bpo-36669: add matmul support to weakref.proxy (GH-12932)
7abb6c0
mdickinson commentedon Apr 26, 2019
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!