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
Gwenaël Samain
cython
Commits
294f23d8
Commit
294f23d8
authored
Jan 01, 2014
by
Stefan Behnel
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
avoid useless metaclass searching overhead when creating Python class without base classes
parent
21021a78
Changes
4
Hide whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
36 additions
and
20 deletions
+36
-20
Cython/Compiler/ExprNodes.py
Cython/Compiler/ExprNodes.py
+10
-2
Cython/Compiler/Nodes.py
Cython/Compiler/Nodes.py
+7
-2
Cython/Utility/ModuleSetupCode.c
Cython/Utility/ModuleSetupCode.c
+2
-0
Cython/Utility/ObjectHandling.c
Cython/Utility/ObjectHandling.c
+17
-16
No files found.
Cython/Compiler/ExprNodes.py
View file @
294f23d8
...
@@ -6966,10 +6966,14 @@ class Py3ClassNode(ExprNode):
...
@@ -6966,10 +6966,14 @@ class Py3ClassNode(ExprNode):
mkw
=
self
.
mkw
.
py_result
()
mkw
=
self
.
mkw
.
py_result
()
else
:
else
:
mkw
=
'NULL'
mkw
=
'NULL'
if
self
.
metaclass
:
metaclass
=
self
.
metaclass
.
result
()
else
:
metaclass
=
"((PyObject*)&__Pyx_DefaultClassType)"
code
.
putln
(
code
.
putln
(
'%s = __Pyx_Py3ClassCreate(%s, %s, %s, %s, %s, %d, %d); %s'
%
(
'%s = __Pyx_Py3ClassCreate(%s, %s, %s, %s, %s, %d, %d); %s'
%
(
self
.
result
(),
self
.
result
(),
self
.
metaclass
.
result
()
,
metaclass
,
cname
,
cname
,
self
.
bases
.
py_result
(),
self
.
bases
.
py_result
(),
self
.
dict
.
py_result
(),
self
.
dict
.
py_result
(),
...
@@ -7163,10 +7167,14 @@ class PyClassNamespaceNode(ExprNode, ModuleNameMixin):
...
@@ -7163,10 +7167,14 @@ class PyClassNamespaceNode(ExprNode, ModuleNameMixin):
mkw
=
self
.
mkw
.
py_result
()
mkw
=
self
.
mkw
.
py_result
()
else
:
else
:
mkw
=
'(PyObject *) NULL'
mkw
=
'(PyObject *) NULL'
if
self
.
metaclass
:
metaclass
=
self
.
metaclass
.
result
()
else
:
metaclass
=
"(PyObject *) NULL"
code
.
putln
(
code
.
putln
(
"%s = __Pyx_Py3MetaclassPrepare(%s, %s, %s, %s, %s, %s, %s); %s"
%
(
"%s = __Pyx_Py3MetaclassPrepare(%s, %s, %s, %s, %s, %s, %s); %s"
%
(
self
.
result
(),
self
.
result
(),
self
.
metaclass
.
result
()
,
metaclass
,
self
.
bases
.
result
(),
self
.
bases
.
result
(),
cname
,
cname
,
qualname
,
qualname
,
...
...
Cython/Compiler/Nodes.py
View file @
294f23d8
...
@@ -4044,8 +4044,13 @@ class PyClassDefNode(ClassDefNode):
...
@@ -4044,8 +4044,13 @@ class PyClassDefNode(ClassDefNode):
mkdict
=
self
.
mkw
mkdict
=
self
.
mkw
else
:
else
:
mkdict
=
None
mkdict
=
None
self
.
metaclass
=
ExprNodes
.
PyClassMetaclassNode
(
if
(
not
mkdict
and
pos
,
mkw
=
mkdict
,
bases
=
self
.
bases
)
self
.
bases
.
is_sequence_constructor
and
not
self
.
bases
.
args
):
pass
# no base classes => no inherited metaclass
else
:
self
.
metaclass
=
ExprNodes
.
PyClassMetaclassNode
(
pos
,
mkw
=
mkdict
,
bases
=
self
.
bases
)
needs_metaclass_calculation
=
False
needs_metaclass_calculation
=
False
else
:
else
:
needs_metaclass_calculation
=
True
needs_metaclass_calculation
=
True
...
...
Cython/Utility/ModuleSetupCode.c
View file @
294f23d8
...
@@ -109,10 +109,12 @@
...
@@ -109,10 +109,12 @@
#define __Pyx_BUILTIN_MODULE_NAME "__builtin__"
#define __Pyx_BUILTIN_MODULE_NAME "__builtin__"
#define __Pyx_PyCode_New(a, k, l, s, f, code, c, n, v, fv, cell, fn, name, fline, lnos) \
#define __Pyx_PyCode_New(a, k, l, s, f, code, c, n, v, fv, cell, fn, name, fline, lnos) \
PyCode_New(a, l, s, f, code, c, n, v, fv, cell, fn, name, fline, lnos)
PyCode_New(a, l, s, f, code, c, n, v, fv, cell, fn, name, fline, lnos)
#define __Pyx_DefaultClassType PyClass_Type
#else
#else
#define __Pyx_BUILTIN_MODULE_NAME "builtins"
#define __Pyx_BUILTIN_MODULE_NAME "builtins"
#define __Pyx_PyCode_New(a, k, l, s, f, code, c, n, v, fv, cell, fn, name, fline, lnos) \
#define __Pyx_PyCode_New(a, k, l, s, f, code, c, n, v, fv, cell, fn, name, fline, lnos) \
PyCode_New(a, k, l, s, f, code, c, n, v, fv, cell, fn, name, fline, lnos)
PyCode_New(a, k, l, s, f, code, c, n, v, fv, cell, fn, name, fline, lnos)
#define __Pyx_DefaultClassType PyType_Type
#endif
#endif
#if PY_VERSION_HEX < 0x02060000
#if PY_VERSION_HEX < 0x02060000
...
...
Cython/Utility/ObjectHandling.c
View file @
294f23d8
...
@@ -830,25 +830,26 @@ static PyObject *__Pyx_Py3ClassCreate(PyObject *metaclass, PyObject *name, PyObj
...
@@ -830,25 +830,26 @@ static PyObject *__Pyx_Py3ClassCreate(PyObject *metaclass, PyObject *name, PyObj
static
PyObject
*
__Pyx_Py3MetaclassPrepare
(
PyObject
*
metaclass
,
PyObject
*
bases
,
PyObject
*
name
,
static
PyObject
*
__Pyx_Py3MetaclassPrepare
(
PyObject
*
metaclass
,
PyObject
*
bases
,
PyObject
*
name
,
PyObject
*
qualname
,
PyObject
*
mkw
,
PyObject
*
modname
,
PyObject
*
doc
)
{
PyObject
*
qualname
,
PyObject
*
mkw
,
PyObject
*
modname
,
PyObject
*
doc
)
{
PyObject
*
prep
;
PyObject
*
pargs
;
PyObject
*
ns
;
PyObject
*
ns
;
if
(
metaclass
)
{
prep
=
__Pyx_PyObject_GetAttrStr
(
metaclass
,
PYIDENT
(
"__prepare__"
));
PyObject
*
prep
=
__Pyx_PyObject_GetAttrStr
(
metaclass
,
PYIDENT
(
"__prepare__"
));
if
(
!
prep
)
{
if
(
prep
)
{
if
(
unlikely
(
!
PyErr_ExceptionMatches
(
PyExc_AttributeError
)))
PyObject
*
pargs
=
PyTuple_Pack
(
2
,
name
,
bases
);
return
NULL
;
if
(
unlikely
(
!
pargs
))
{
PyErr_Clear
();
Py_DECREF
(
prep
);
ns
=
PyDict_New
();
return
NULL
;
}
else
{
}
pargs
=
PyTuple_Pack
(
2
,
name
,
bases
);
ns
=
PyObject_Call
(
prep
,
pargs
,
mkw
);
if
(
unlikely
(
!
pargs
))
{
Py_DECREF
(
prep
);
Py_DECREF
(
prep
);
return
NULL
;
Py_DECREF
(
pargs
);
}
else
{
if
(
unlikely
(
!
PyErr_ExceptionMatches
(
PyExc_AttributeError
)))
return
NULL
;
PyErr_Clear
();
ns
=
PyDict_New
();
}
}
ns
=
PyObject_Call
(
prep
,
pargs
,
mkw
);
}
else
{
Py_DECREF
(
prep
);
ns
=
PyDict_New
();
Py_DECREF
(
pargs
);
}
}
if
(
unlikely
(
!
ns
))
if
(
unlikely
(
!
ns
))
...
...
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