Author: [email protected]
Branch: py3.5-raffael_t
Changeset: r83943:6eacb28b58d1
Date: 2016-03-22 18:22 +0100
http://bitbucket.org/pypy/pypy/changeset/6eacb28b58d1/
Log: Define matmul method in module, Add to dict in objspace
diff --git a/pypy/module/cpyext/number.py b/pypy/module/cpyext/number.py
--- a/pypy/module/cpyext/number.py
+++ b/pypy/module/cpyext/number.py
@@ -89,6 +89,7 @@
('Xor', 'xor'),
('Or', 'or_'),
('Divmod', 'divmod'),
+ ('MatrixMultiply', 'matmul')
]:
make_numbermethod(name, spacemeth)
if name != 'Divmod':
diff --git a/pypy/module/operator/__init__.py b/pypy/module/operator/__init__.py
--- a/pypy/module/operator/__init__.py
+++ b/pypy/module/operator/__init__.py
@@ -28,7 +28,7 @@
'le', 'lshift', 'lt', 'mod', 'mul',
'ne', 'neg', 'not_', 'or_',
'pos', 'pow', 'rshift', 'setitem',
- 'sub', 'truediv', 'truth', 'xor',
+ 'sub', 'truediv', 'matmul', 'truth', 'xor',
'iadd', 'iand', 'iconcat', 'ifloordiv',
'ilshift', 'imod', 'imul', 'ior', 'ipow',
'irshift', 'isub', 'itruediv', 'ixor', '_length_hint',
@@ -72,6 +72,7 @@
'__sub__' : 'sub',
'__truediv__' : 'truediv',
'__xor__' : 'xor',
+ '__matmul__' : 'matmul',
# in-place
'__iadd__' : 'iadd',
'__iand__' : 'iand',
diff --git a/pypy/module/operator/interp_operator.py
b/pypy/module/operator/interp_operator.py
--- a/pypy/module/operator/interp_operator.py
+++ b/pypy/module/operator/interp_operator.py
@@ -143,6 +143,10 @@
'xor(a, b) -- Same as a ^ b.'
return space.xor(w_a, w_b)
+def matmul(space, w_a, w_b):
+ 'matmul(a, b) -- Same as a @ b.'
+ return space.matmul(w_a, w_b)
+
# in-place operations
def iadd(space, w_obj1, w_obj2):
diff --git a/pypy/objspace/std/util.py b/pypy/objspace/std/util.py
--- a/pypy/objspace/std/util.py
+++ b/pypy/objspace/std/util.py
@@ -15,7 +15,7 @@
BINARY_BITWISE_OPS = {'and': '&', 'lshift': '<<', 'or': '|', 'rshift': '>>',
'xor': '^'}
BINARY_OPS = dict(add='+', div='/', floordiv='//', mod='%', mul='*', sub='-',
- truediv='/', **BINARY_BITWISE_OPS)
+ truediv='/', matmul='@', **BINARY_BITWISE_OPS)
COMMUTATIVE_OPS = ('add', 'mul', 'and', 'or', 'xor')
_______________________________________________
pypy-commit mailing list
[email protected]
https://mail.python.org/mailman/listinfo/pypy-commit