Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
P
Pyston
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
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Commits
Issue Boards
Open sidebar
Boxiang Sun
Pyston
Commits
ee5b6d49
Commit
ee5b6d49
authored
Aug 12, 2015
by
Kevin Modzelewski
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Optimize some type-checking
parent
61a68d3d
Changes
6
Hide whitespace changes
Inline
Side-by-side
Showing
6 changed files
with
10 additions
and
11 deletions
+10
-11
src/capi/typeobject.cpp
src/capi/typeobject.cpp
+2
-2
src/runtime/builtin_modules/builtins.cpp
src/runtime/builtin_modules/builtins.cpp
+1
-1
src/runtime/objmodel.cpp
src/runtime/objmodel.cpp
+0
-5
src/runtime/objmodel.h
src/runtime/objmodel.h
+5
-1
src/runtime/tuple.cpp
src/runtime/tuple.cpp
+1
-1
src/runtime/types.cpp
src/runtime/types.cpp
+1
-1
No files found.
src/capi/typeobject.cpp
View file @
ee5b6d49
...
...
@@ -2558,11 +2558,11 @@ static int mro_internal(PyTypeObject* type) noexcept {
extern
"C"
int
PyType_IsSubtype
(
PyTypeObject
*
a
,
PyTypeObject
*
b
)
noexcept
{
PyObject
*
mro
;
if
(
!
(
a
->
tp_flags
&
Py_TPFLAGS_HAVE_CLASS
))
if
(
unlikely
(
!
(
a
->
tp_flags
&
Py_TPFLAGS_HAVE_CLASS
)
))
return
b
==
a
||
b
==
&
PyBaseObject_Type
;
mro
=
a
->
tp_mro
;
if
(
mro
!=
NULL
)
{
if
(
likely
(
mro
!=
NULL
)
)
{
/* Deal with multiple inheritance without recursion
by walking the MRO tuple */
Py_ssize_t
i
,
n
;
...
...
src/runtime/builtin_modules/builtins.cpp
View file @
ee5b6d49
...
...
@@ -468,7 +468,7 @@ template <ExceptionStyle S> Box* getattrFunc(Box* obj, Box* _str, Box* default_v
throw
e
;
}
if
(
!
isSubclass
(
_str
->
cls
,
str_cls
))
{
if
(
!
PyString_Check
(
_str
))
{
if
(
S
==
CAPI
)
{
PyErr_SetString
(
TypeError
,
"getattr(): attribute name must be string"
);
return
NULL
;
...
...
src/runtime/objmodel.cpp
View file @
ee5b6d49
...
...
@@ -244,11 +244,6 @@ extern "C" void my_assert(bool b) {
assert
(
b
);
}
extern
"C"
bool
isSubclass
(
BoxedClass
*
child
,
BoxedClass
*
parent
)
{
STAT_TIMER
(
t0
,
"us_timer_isSubclass"
,
10
);
return
PyType_IsSubtype
(
child
,
parent
);
}
extern
"C"
void
assertFail
(
Box
*
assertion_type
,
Box
*
msg
)
{
RELEASE_ASSERT
(
assertion_type
->
cls
==
type_cls
,
"%s"
,
assertion_type
->
cls
->
tp_name
);
if
(
msg
)
{
...
...
src/runtime/objmodel.h
View file @
ee5b6d49
...
...
@@ -100,7 +100,11 @@ extern "C" Box** unpackIntoArray(Box* obj, int64_t expected_size);
extern
"C"
void
assertNameDefined
(
bool
b
,
const
char
*
name
,
BoxedClass
*
exc_cls
,
bool
local_var_msg
);
extern
"C"
void
assertFailDerefNameDefined
(
const
char
*
name
);
extern
"C"
void
assertFail
(
Box
*
assertion_type
,
Box
*
msg
);
extern
"C"
bool
isSubclass
(
BoxedClass
*
child
,
BoxedClass
*
parent
);
inline
bool
isSubclass
(
BoxedClass
*
child
,
BoxedClass
*
parent
)
{
return
child
==
parent
||
PyType_IsSubtype
(
child
,
parent
);
}
extern
"C"
BoxedClosure
*
createClosure
(
BoxedClosure
*
parent_closure
,
size_t
size
);
Box
*
getiter
(
Box
*
o
);
...
...
src/runtime/tuple.cpp
View file @
ee5b6d49
...
...
@@ -328,7 +328,7 @@ Box* tupleCount(BoxedTuple* self, Box* elt) {
}
extern
"C"
Box
*
tupleNew
(
Box
*
_cls
,
BoxedTuple
*
args
,
BoxedDict
*
kwargs
)
{
if
(
!
isSubclass
(
_cls
->
cls
,
type
_cls
))
if
(
!
PyType_Check
(
_cls
))
raiseExcHelper
(
TypeError
,
"tuple.__new__(X): X is not a type object (%s)"
,
getTypeName
(
_cls
));
BoxedClass
*
cls
=
static_cast
<
BoxedClass
*>
(
_cls
);
...
...
src/runtime/types.cpp
View file @
ee5b6d49
...
...
@@ -201,7 +201,7 @@ void* BoxVar::operator new(size_t size, BoxedClass* cls, size_t nitems) {
assert
(
cls
);
// See definition of BoxedTuple for some notes on why we need this special case:
ASSERT
(
isSubclass
(
cls
,
tuple_cls
)
||
cls
->
tp_basicsize
>=
size
,
"%s"
,
cls
->
tp_name
);
ASSERT
(
cls
->
tp_basicsize
>=
size
||
isSubclass
(
cls
,
tuple_cls
)
,
"%s"
,
cls
->
tp_name
);
assert
(
cls
->
tp_itemsize
>
0
);
assert
(
cls
->
tp_alloc
);
...
...
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