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
e5b1dccb
Commit
e5b1dccb
authored
Mar 07, 2013
by
Stefan Behnel
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
factor out builtin access code
parent
afba831b
Changes
3
Show whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
17 additions
and
37 deletions
+17
-37
Cython/Compiler/Code.py
Cython/Compiler/Code.py
+3
-4
Cython/Compiler/ExprNodes.py
Cython/Compiler/ExprNodes.py
+3
-7
Cython/Utility/ObjectHandling.c
Cython/Utility/ObjectHandling.c
+11
-26
No files found.
Cython/Compiler/Code.py
View file @
e5b1dccb
...
...
@@ -1107,11 +1107,10 @@ class GlobalState(object):
def
put_cached_builtin_init
(
self
,
pos
,
name
,
cname
):
w
=
self
.
parts
[
'cached_builtins'
]
interned_cname
=
self
.
get_interned_identifier
(
name
).
cname
from
ExprNodes
import
get_name_interned_utility_code
self
.
use_utility_code
(
get_name_interned_utility_code
)
w
.
putln
(
'%s = __Pyx_Get
Name(%s,
%s); if (!%s) %s'
%
(
self
.
use_utility_code
(
UtilityCode
.
load_cached
(
"GetBuiltinName"
,
"ObjectHandling.c"
)
)
w
.
putln
(
'%s = __Pyx_Get
BuiltinName(
%s); if (!%s) %s'
%
(
cname
,
Naming
.
builtins_cname
,
interned_cname
,
cname
,
w
.
error_goto
(
pos
)))
...
...
Cython/Compiler/ExprNodes.py
View file @
e5b1dccb
...
...
@@ -1767,11 +1767,11 @@ class NameNode(AtomicExprNode):
elif
entry
.
is_builtin
:
assert
entry
.
type
.
is_pyobject
,
"Python global or builtin not a Python object"
interned_cname
=
code
.
intern_identifier
(
self
.
entry
.
name
)
code
.
globalstate
.
use_utility_code
(
get_name_interned_utility_code
)
code
.
globalstate
.
use_utility_code
(
UtilityCode
.
load_cached
(
"GetBuiltinName"
,
"ObjectHandling.c"
))
code
.
putln
(
'%s = __Pyx_Get
Name(%s,
%s); %s'
%
(
'%s = __Pyx_Get
BuiltinName(
%s); %s'
%
(
self
.
result
(),
Naming
.
builtins_cname
,
interned_cname
,
code
.
error_goto_if_null
(
self
.
result
(),
self
.
pos
)))
code
.
put_gotref
(
self
.
py_result
())
...
...
@@ -10425,10 +10425,6 @@ class DocstringRefNode(ExprNode):
#
#------------------------------------------------------------------------------------
get_name_interned_utility_code
=
UtilityCode
.
load_cached
(
"GetGlobalName"
,
"ObjectHandling.c"
)
#------------------------------------------------------------------------------------
pyerr_occurred_withgil_utility_code
=
UtilityCode
(
proto
=
"""
static CYTHON_INLINE int __Pyx_ErrOccurredWithGIL(void); /* proto */
...
...
Cython/Utility/ObjectHandling.c
View file @
e5b1dccb
...
...
@@ -578,23 +578,17 @@ static CYTHON_INLINE PyObject* __Pyx_PyBoolOrNull_FromLong(long b) {
return
unlikely
(
b
<
0
)
?
NULL
:
__Pyx_PyBool_FromLong
(
b
);
}
/////////////// Get
Global
Name.proto ///////////////
/////////////// Get
Builtin
Name.proto ///////////////
static
PyObject
*
__Pyx_Get
Name
(
PyObject
*
dict
,
PyObject
*
name
);
/*proto*/
static
PyObject
*
__Pyx_Get
BuiltinName
(
PyObject
*
name
);
/*proto*/
/////////////// Get
Global
Name ///////////////
/////////////// Get
Builtin
Name ///////////////
//@requires: PyObjectGetAttrStr
//@substitute: naming
static
PyObject
*
__Pyx_GetName
(
PyObject
*
dict
,
PyObject
*
name
)
{
PyObject
*
result
;
result
=
__Pyx_PyObject_GetAttrStr
(
dict
,
name
);
if
(
!
result
)
{
if
(
dict
!=
$
builtins_cname
)
{
PyErr_Clear
();
result
=
__Pyx_PyObject_GetAttrStr
(
$
builtins_cname
,
name
);
}
if
(
!
result
)
{
static
PyObject
*
__Pyx_GetBuiltinName
(
PyObject
*
name
)
{
PyObject
*
result
=
__Pyx_PyObject_GetAttrStr
(
$
builtins_cname
,
name
);
if
(
unlikely
(
!
result
))
{
PyErr_Format
(
PyExc_NameError
,
#if PY_MAJOR_VERSION >= 3
"name '%U' is not defined"
,
name
);
...
...
@@ -602,7 +596,6 @@ static PyObject *__Pyx_GetName(PyObject *dict, PyObject *name) {
"name '%s' is not defined"
,
PyString_AS_STRING
(
name
));
#endif
}
}
return
result
;
}
...
...
@@ -611,7 +604,7 @@ static PyObject *__Pyx_GetName(PyObject *dict, PyObject *name) {
static
CYTHON_INLINE
PyObject
*
__Pyx_GetModuleGlobalName
(
PyObject
*
name
);
/*proto*/
/////////////// GetModuleGlobalName ///////////////
//@requires:
PyObjectGetAttrStr
//@requires:
GetBuiltinName
//@substitute: naming
static
CYTHON_INLINE
PyObject
*
__Pyx_GetModuleGlobalName
(
PyObject
*
name
)
{
...
...
@@ -626,15 +619,7 @@ static CYTHON_INLINE PyObject *__Pyx_GetModuleGlobalName(PyObject *name) {
if
(
!
result
)
{
PyErr_Clear
();
#endif
result
=
__Pyx_PyObject_GetAttrStr
(
$
builtins_cname
,
name
);
if
(
unlikely
(
!
result
))
{
PyErr_Format
(
PyExc_NameError
,
#if PY_MAJOR_VERSION >= 3
"name '%U' is not defined"
,
name
);
#else
"name '%s' is not defined"
,
PyString_AS_STRING
(
name
));
#endif
}
result
=
__Pyx_GetBuiltinName
(
name
);
}
return
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