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
ee4fbd41
Commit
ee4fbd41
authored
Jul 19, 2015
by
Kevin Modzelewski
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Optimize hcls ctor; make a few more strings immortal
parent
41bd1480
Changes
3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
14 additions
and
11 deletions
+14
-11
src/runtime/classobj.cpp
src/runtime/classobj.cpp
+4
-2
src/runtime/import.cpp
src/runtime/import.cpp
+8
-5
src/runtime/types.h
src/runtime/types.h
+2
-4
No files found.
src/runtime/classobj.cpp
View file @
ee4fbd41
...
...
@@ -110,8 +110,10 @@ Box* classobjNew(Box* _cls, Box* _name, Box* _bases, Box** _args) {
}
// Note: make sure to do this after assigning the attrs, since it will overwrite any defined __name__
made
->
setattr
(
internStringMortal
(
"__name__"
),
name
,
NULL
);
made
->
setattr
(
internStringMortal
(
"__bases__"
),
bases
,
NULL
);
static
BoxedString
*
name_str
=
internStringImmortal
(
"__name__"
);
static
BoxedString
*
bases_str
=
internStringImmortal
(
"__bases__"
);
made
->
setattr
(
name_str
,
name
,
NULL
);
made
->
setattr
(
bases_str
,
bases
,
NULL
);
return
made
;
}
...
...
src/runtime/import.cpp
View file @
ee4fbd41
...
...
@@ -184,7 +184,8 @@ struct SearchResult {
};
SearchResult
findModule
(
const
std
::
string
&
name
,
const
std
::
string
&
full_name
,
BoxedList
*
path_list
)
{
BoxedList
*
meta_path
=
static_cast
<
BoxedList
*>
(
sys_module
->
getattr
(
internStringMortal
(
"meta_path"
)));
static
BoxedString
*
meta_path_str
=
internStringImmortal
(
"meta_path"
);
BoxedList
*
meta_path
=
static_cast
<
BoxedList
*>
(
sys_module
->
getattr
(
meta_path_str
));
if
(
!
meta_path
||
meta_path
->
cls
!=
list_cls
)
raiseExcHelper
(
RuntimeError
,
"sys.meta_path must be a list of import hooks"
);
...
...
@@ -208,12 +209,13 @@ SearchResult findModule(const std::string& name, const std::string& full_name, B
raiseExcHelper
(
RuntimeError
,
"sys.path must be a list of directory names"
);
}
BoxedList
*
path_hooks
=
static_cast
<
BoxedList
*>
(
sys_module
->
getattr
(
internStringMortal
(
"path_hooks"
)));
static
BoxedString
*
path_hooks_str
=
internStringImmortal
(
"path_hooks"
);
BoxedList
*
path_hooks
=
static_cast
<
BoxedList
*>
(
sys_module
->
getattr
(
path_hooks_str
));
if
(
!
path_hooks
||
path_hooks
->
cls
!=
list_cls
)
raiseExcHelper
(
RuntimeError
,
"sys.path_hooks must be a list of import hooks"
);
BoxedDict
*
path_importer_cache
=
static_cast
<
BoxedDict
*>
(
sys_module
->
getattr
(
internStringMortal
(
"path_importer_cache"
)
));
static
BoxedString
*
path_importer_cache_str
=
internStringImmortal
(
"path_importer_cache"
);
BoxedDict
*
path_importer_cache
=
static_cast
<
BoxedDict
*>
(
sys_module
->
getattr
(
path_importer_cache_str
));
if
(
!
path_importer_cache
||
path_importer_cache
->
cls
!=
dict_cls
)
raiseExcHelper
(
RuntimeError
,
"sys.path_importer_cache must be a dict"
);
...
...
@@ -865,7 +867,8 @@ Box* impIsBuiltin(Box* _name) {
if
(
!
PyString_Check
(
_name
))
raiseExcHelper
(
TypeError
,
"must be string, not %s"
,
getTypeName
(
_name
));
BoxedTuple
*
builtin_modules
=
(
BoxedTuple
*
)
sys_module
->
getattr
(
internStringMortal
(
"builtin_module_names"
));
static
BoxedString
*
builtin_module_names_str
=
internStringImmortal
(
"builtin_module_names"
);
BoxedTuple
*
builtin_modules
=
(
BoxedTuple
*
)
sys_module
->
getattr
(
builtin_module_names_str
);
RELEASE_ASSERT
(
PyTuple_Check
(
builtin_modules
),
""
);
for
(
Box
*
m
:
builtin_modules
->
pyElements
())
{
if
(
compare
(
m
,
_name
,
AST_TYPE
::
Eq
)
==
True
)
...
...
src/runtime/types.h
View file @
ee4fbd41
...
...
@@ -326,11 +326,9 @@ public:
private:
HiddenClass
(
HCType
type
)
:
type
(
type
)
{}
HiddenClass
(
HiddenClass
*
parent
)
:
type
(
NORMAL
),
attr_offsets
(),
attrwrapper_offset
(
parent
->
attrwrapper_offset
)
{
HiddenClass
(
HiddenClass
*
parent
)
:
type
(
NORMAL
),
attr_offsets
(
parent
->
attr_offsets
),
attrwrapper_offset
(
parent
->
attrwrapper_offset
)
{
assert
(
parent
->
type
==
NORMAL
);
for
(
auto
&
p
:
parent
->
attr_offsets
)
{
this
->
attr_offsets
.
insert
(
p
);
}
}
// These fields only make sense for NORMAL or SINGLETON hidden classes:
...
...
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