Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
C
cython
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
0
Merge Requests
0
Analytics
Analytics
Repository
Value Stream
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Commits
Issue Boards
Open sidebar
Kirill Smelkov
cython
Commits
1fed1015
Commit
1fed1015
authored
Aug 30, 2014
by
Stefan Behnel
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
optimise method calls in backport of matix multiplication
parent
4cb1368a
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
34 additions
and
6 deletions
+34
-6
Cython/Utility/ObjectHandling.c
Cython/Utility/ObjectHandling.c
+34
-6
No files found.
Cython/Utility/ObjectHandling.c
View file @
1fed1015
...
...
@@ -1359,16 +1359,46 @@ static PyObject* __Pyx_PyNumber_InPlaceMatrixMultiply(PyObject* x, PyObject* y);
/////////////// MatrixMultiply ///////////////
//@requires: PyObjectGetAttrStr
//@requires: PyObjectCallOneArg
#if PY_VERSION_HEX < 0x03050000
static
PyObject
*
__Pyx_PyObject_CallMatrixMethod
(
PyObject
*
method
,
PyObject
*
arg
)
{
// NOTE: eats the method reference
PyObject
*
result
=
NULL
;
#if CYTHON_COMPILING_IN_CPYTHON
if
(
likely
(
PyMethod_Check
(
method
)))
{
PyObject
*
self
=
PyMethod_GET_SELF
(
method
);
if
(
likely
(
self
))
{
PyObject
*
args
;
PyObject
*
function
=
PyMethod_GET_FUNCTION
(
method
);
args
=
PyTuple_New
(
2
);
if
(
unlikely
(
!
args
))
goto
bad
;
Py_INCREF
(
self
);
PyTuple_SET_ITEM
(
args
,
0
,
self
);
Py_INCREF
(
arg
);
PyTuple_SET_ITEM
(
args
,
1
,
arg
);
Py_INCREF
(
function
);
Py_DECREF
(
method
);
method
=
NULL
;
result
=
__Pyx_PyObject_Call
(
function
,
args
,
NULL
);
Py_DECREF
(
args
);
Py_DECREF
(
function
);
return
result
;
}
}
#endif
result
=
__Pyx_PyObject_CallOneArg
(
method
,
arg
);
bad:
Py_DECREF
(
method
);
return
result
;
}
static
PyObject
*
__Pyx_PyNumber_MatrixMultiply
(
PyObject
*
x
,
PyObject
*
y
)
{
PyObject
*
func
;
// FIXME: make subtype aware
// see note at https://docs.python.org/3/reference/datamodel.html#emulating-numeric-types
func
=
__Pyx_PyObject_GetAttrStr
(
x
,
PYIDENT
(
"__matmul__"
));
if
(
func
)
{
PyObject
*
result
=
PyObject_CallFunctionObjArgs
(
func
,
y
,
NULL
);
Py_DECREF
(
func
);
PyObject
*
result
=
__Pyx_PyObject_CallMatrixMethod
(
func
,
y
);
if
(
result
!=
Py_NotImplemented
)
return
result
;
Py_DECREF
(
result
);
...
...
@@ -1379,8 +1409,7 @@ static PyObject* __Pyx_PyNumber_MatrixMultiply(PyObject* x, PyObject* y) {
}
func
=
__Pyx_PyObject_GetAttrStr
(
y
,
PYIDENT
(
"__rmatmul__"
));
if
(
func
)
{
PyObject
*
result
=
PyObject_CallFunctionObjArgs
(
func
,
x
,
NULL
);
Py_DECREF
(
func
);
PyObject
*
result
=
__Pyx_PyObject_CallMatrixMethod
(
func
,
x
);
return
result
;
}
Py_INCREF
(
Py_NotImplemented
);
...
...
@@ -1391,8 +1420,7 @@ static PyObject* __Pyx_PyNumber_InPlaceMatrixMultiply(PyObject* x, PyObject* y)
PyObject
*
func
;
func
=
__Pyx_PyObject_GetAttrStr
(
x
,
PYIDENT
(
"__imatmul__"
));
if
(
func
)
{
PyObject
*
result
=
PyObject_CallFunctionObjArgs
(
func
,
y
,
NULL
);
Py_DECREF
(
func
);
PyObject
*
result
=
__Pyx_PyObject_CallMatrixMethod
(
func
,
y
);
if
(
result
!=
Py_NotImplemented
)
return
result
;
Py_DECREF
(
result
);
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment