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
Labels
Merge Requests
0
Merge Requests
0
Analytics
Analytics
Repository
Value Stream
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Commits
Open sidebar
nexedi
cython
Commits
94292508
Commit
94292508
authored
Oct 24, 2007
by
Robert Bradshaw
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
cache builtins at module level
parent
fce655c1
Changes
3
Show whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
19 additions
and
17 deletions
+19
-17
Cython/Compiler/ModuleNode.py
Cython/Compiler/ModuleNode.py
+2
-2
Cython/Compiler/Nodes.py
Cython/Compiler/Nodes.py
+1
-1
Cython/Compiler/Symtab.py
Cython/Compiler/Symtab.py
+16
-14
No files found.
Cython/Compiler/ModuleNode.py
View file @
94292508
...
@@ -1293,7 +1293,7 @@ class ModuleNode(Nodes.Node, Nodes.BlockNode):
...
@@ -1293,7 +1293,7 @@ class ModuleNode(Nodes.Node, Nodes.BlockNode):
code
.
put_decref
(
"((PyObject*)%s)"
%
type
.
typeptr_cname
,
PyrexTypes
.
py_object_type
)
code
.
put_decref
(
"((PyObject*)%s)"
%
type
.
typeptr_cname
,
PyrexTypes
.
py_object_type
)
if
Options
.
cache_builtins
:
if
Options
.
cache_builtins
:
code
.
putln
(
"/*--- Builtin cleanup code ---*/"
)
code
.
putln
(
"/*--- Builtin cleanup code ---*/"
)
for
entry
in
env
.
builtin_scope
().
cached_entrie
s
:
for
entry
in
env
.
cached_builtin
s
:
code
.
put_var_decref_clear
(
entry
)
code
.
put_var_decref_clear
(
entry
)
code
.
putln
(
"/*--- Intern cleanup code ---*/"
)
code
.
putln
(
"/*--- Intern cleanup code ---*/"
)
for
entry
in
env
.
pynum_entries
:
for
entry
in
env
.
pynum_entries
:
...
@@ -1370,7 +1370,7 @@ class ModuleNode(Nodes.Node, Nodes.BlockNode):
...
@@ -1370,7 +1370,7 @@ class ModuleNode(Nodes.Node, Nodes.BlockNode):
def
generate_builtin_init_code
(
self
,
env
,
code
):
def
generate_builtin_init_code
(
self
,
env
,
code
):
# Lookup and cache builtin objects.
# Lookup and cache builtin objects.
if
Options
.
cache_builtins
:
if
Options
.
cache_builtins
:
for
entry
in
env
.
builtin_scope
().
cached_entrie
s
:
for
entry
in
env
.
cached_builtin
s
:
if
Options
.
intern_names
:
if
Options
.
intern_names
:
#assert entry.interned_cname is not None
#assert entry.interned_cname is not None
code
.
putln
(
code
.
putln
(
...
...
Cython/Compiler/Nodes.py
View file @
94292508
...
@@ -129,7 +129,7 @@ class BlockNode:
...
@@ -129,7 +129,7 @@ class BlockNode:
del
entries
[:]
del
entries
[:]
def
generate_cached_builtins_decls
(
self
,
env
,
code
):
def
generate_cached_builtins_decls
(
self
,
env
,
code
):
entries
=
env
.
builtin_scope
().
undeclared_cached_entrie
s
entries
=
env
.
global_scope
().
undeclared_cached_builtin
s
if
len
(
entries
)
>
0
:
if
len
(
entries
)
>
0
:
code
.
putln
(
""
)
code
.
putln
(
""
)
for
entry
in
entries
:
for
entry
in
entries
:
...
...
Cython/Compiler/Symtab.py
View file @
94292508
...
@@ -560,8 +560,6 @@ class BuiltinScope(Scope):
...
@@ -560,8 +560,6 @@ class BuiltinScope(Scope):
for
name
,
definition
in
self
.
builtin_entries
.
iteritems
():
for
name
,
definition
in
self
.
builtin_entries
.
iteritems
():
cname
,
type
=
definition
cname
,
type
=
definition
self
.
declare_var
(
name
,
type
,
None
,
cname
)
self
.
declare_var
(
name
,
type
,
None
,
cname
)
self
.
cached_entries
=
[]
self
.
undeclared_cached_entries
=
[]
def
declare_builtin
(
self
,
name
,
pos
):
def
declare_builtin
(
self
,
name
,
pos
):
if
not
hasattr
(
__builtin__
,
name
):
if
not
hasattr
(
__builtin__
,
name
):
...
@@ -569,16 +567,6 @@ class BuiltinScope(Scope):
...
@@ -569,16 +567,6 @@ class BuiltinScope(Scope):
return
self
.
outer_scope
.
declare_builtin
(
name
,
pos
)
return
self
.
outer_scope
.
declare_builtin
(
name
,
pos
)
else
:
else
:
error
(
pos
,
"undeclared name not builtin: %s"
%
name
)
error
(
pos
,
"undeclared name not builtin: %s"
%
name
)
entry
=
self
.
declare
(
name
,
name
,
py_object_type
,
pos
)
if
Options
.
cache_builtins
:
entry
.
is_builtin
=
1
entry
.
is_const
=
1
entry
.
cname
=
Naming
.
builtin_prefix
+
name
self
.
cached_entries
.
append
(
entry
)
self
.
undeclared_cached_entries
.
append
(
entry
)
else
:
entry
.
is_builtin
=
1
return
entry
def
declare_builtin_cfunction
(
self
,
name
,
type
,
cname
,
python_equiv
=
None
,
def
declare_builtin_cfunction
(
self
,
name
,
type
,
cname
,
python_equiv
=
None
,
utility_code
=
None
):
utility_code
=
None
):
...
@@ -688,6 +676,8 @@ class ModuleScope(Scope):
...
@@ -688,6 +676,8 @@ class ModuleScope(Scope):
self
.
types_imported
=
{}
self
.
types_imported
=
{}
self
.
pynum_entries
=
[]
self
.
pynum_entries
=
[]
self
.
has_extern_class
=
0
self
.
has_extern_class
=
0
self
.
cached_builtins
=
[]
self
.
undeclared_cached_builtins
=
[]
def
qualifying_scope
(
self
):
def
qualifying_scope
(
self
):
return
self
.
parent_module
return
self
.
parent_module
...
@@ -696,8 +686,20 @@ class ModuleScope(Scope):
...
@@ -696,8 +686,20 @@ class ModuleScope(Scope):
return
self
return
self
def
declare_builtin
(
self
,
name
,
pos
):
def
declare_builtin
(
self
,
name
,
pos
):
entry
=
Scope
.
declare_builtin
(
self
,
name
,
pos
)
if
not
hasattr
(
__builtin__
,
name
):
#entry.interned_cname = self.intern(name)
if
self
.
outer_scope
is
not
None
:
return
self
.
outer_scope
.
declare_builtin
(
name
,
pos
)
else
:
error
(
pos
,
"undeclared name not builtin: %s"
%
name
)
entry
=
self
.
declare
(
name
,
name
,
py_object_type
,
pos
)
if
Options
.
cache_builtins
:
entry
.
is_builtin
=
1
entry
.
is_const
=
1
entry
.
cname
=
Naming
.
builtin_prefix
+
name
self
.
cached_builtins
.
append
(
entry
)
self
.
undeclared_cached_builtins
.
append
(
entry
)
else
:
entry
.
is_builtin
=
1
return
entry
return
entry
def
intern
(
self
,
name
):
def
intern
(
self
,
name
):
...
...
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