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
d1e5d1f6
Commit
d1e5d1f6
authored
Feb 12, 2013
by
Stefan Behnel
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
replace lots of dynamically created string constants in utility code by static Python constants
parent
d1e3aee9
Changes
7
Hide whitespace changes
Inline
Side-by-side
Showing
7 changed files
with
39 additions
and
23 deletions
+39
-23
Cython/Utility/Builtins.c
Cython/Utility/Builtins.c
+3
-3
Cython/Utility/CythonFunction.c
Cython/Utility/CythonFunction.c
+1
-1
Cython/Utility/Generator.c
Cython/Utility/Generator.c
+3
-3
Cython/Utility/ObjectHandling.c
Cython/Utility/ObjectHandling.c
+7
-7
Cython/Utility/Optimize.c
Cython/Utility/Optimize.c
+20
-4
Cython/Utility/Printing.c
Cython/Utility/Printing.c
+4
-4
Cython/Utility/TypeConversion.c
Cython/Utility/TypeConversion.c
+1
-1
No files found.
Cython/Utility/Builtins.c
View file @
d1e5d1f6
...
@@ -15,7 +15,7 @@ static PyObject* __Pyx_Globals(void) {
...
@@ -15,7 +15,7 @@ static PyObject* __Pyx_Globals(void) {
Py_ssize_t
i
;
Py_ssize_t
i
;
//PyObject *d;
//PyObject *d;
PyObject
*
names
=
NULL
;
PyObject
*
names
=
NULL
;
PyObject
*
globals
=
PyObject_GetAttr
String
(
$
module_cname
,
"__dict__"
);
PyObject
*
globals
=
PyObject_GetAttr
(
$
module_cname
,
PYIDENT
(
"__dict__"
)
);
if
(
!
globals
)
{
if
(
!
globals
)
{
PyErr_SetString
(
PyExc_TypeError
,
PyErr_SetString
(
PyExc_TypeError
,
"current module must have __dict__ attribute"
);
"current module must have __dict__ attribute"
);
...
@@ -111,8 +111,8 @@ static PyObject* __Pyx_PyExec3(PyObject* o, PyObject* globals, PyObject* locals)
...
@@ -111,8 +111,8 @@ static PyObject* __Pyx_PyExec3(PyObject* o, PyObject* globals, PyObject* locals)
locals
=
globals
;
locals
=
globals
;
}
}
if
(
PyDict_GetItem
String
(
globals
,
"__builtins__"
)
==
NULL
)
{
if
(
PyDict_GetItem
(
globals
,
PYIDENT
(
"__builtins__"
)
)
==
NULL
)
{
if
(
PyDict_SetItem
String
(
globals
,
"__builtins__"
,
PyEval_GetBuiltins
())
<
0
)
if
(
PyDict_SetItem
(
globals
,
PYIDENT
(
"__builtins__"
)
,
PyEval_GetBuiltins
())
<
0
)
goto
bad
;
goto
bad
;
}
}
...
...
Cython/Utility/CythonFunction.c
View file @
d1e5d1f6
...
@@ -701,7 +701,7 @@ static PyObject *
...
@@ -701,7 +701,7 @@ static PyObject *
_obj_to_str
(
PyObject
*
obj
)
_obj_to_str
(
PyObject
*
obj
)
{
{
if
(
PyType_Check
(
obj
))
if
(
PyType_Check
(
obj
))
return
PyObject_GetAttr
String
(
obj
,
"__name__"
);
return
PyObject_GetAttr
(
obj
,
PYIDENT
(
"__name__"
)
);
else
else
return
PyObject_Str
(
obj
);
return
PyObject_Str
(
obj
);
}
}
...
...
Cython/Utility/Generator.c
View file @
d1e5d1f6
...
@@ -123,7 +123,7 @@ static int __Pyx_PyGen_FetchStopIterationValue(PyObject **pvalue) {
...
@@ -123,7 +123,7 @@ static int __Pyx_PyGen_FetchStopIterationValue(PyObject **pvalue) {
Py_DECREF
(
ev
);
Py_DECREF
(
ev
);
#else
#else
{
{
PyObject
*
args
=
PyObject_GetAttr
String
(
ev
,
"args"
);
PyObject
*
args
=
PyObject_GetAttr
(
ev
,
PYIDENT
(
"args"
)
);
Py_DECREF
(
ev
);
Py_DECREF
(
ev
);
if
(
likely
(
args
))
{
if
(
likely
(
args
))
{
value
=
PyObject_GetItem
(
args
,
0
);
value
=
PyObject_GetItem
(
args
,
0
);
...
@@ -310,7 +310,7 @@ static int __Pyx_Generator_CloseIter(__pyx_GeneratorObject *gen, PyObject *yf) {
...
@@ -310,7 +310,7 @@ static int __Pyx_Generator_CloseIter(__pyx_GeneratorObject *gen, PyObject *yf) {
}
else
{
}
else
{
PyObject
*
meth
;
PyObject
*
meth
;
gen
->
is_running
=
1
;
gen
->
is_running
=
1
;
meth
=
PyObject_GetAttr
String
(
yf
,
"close"
);
meth
=
PyObject_GetAttr
(
yf
,
PYIDENT
(
"close"
)
);
if
(
unlikely
(
!
meth
))
{
if
(
unlikely
(
!
meth
))
{
if
(
!
PyErr_ExceptionMatches
(
PyExc_AttributeError
))
{
if
(
!
PyErr_ExceptionMatches
(
PyExc_AttributeError
))
{
PyErr_WriteUnraisable
(
yf
);
PyErr_WriteUnraisable
(
yf
);
...
@@ -402,7 +402,7 @@ static PyObject *__Pyx_Generator_Throw(PyObject *self, PyObject *args) {
...
@@ -402,7 +402,7 @@ static PyObject *__Pyx_Generator_Throw(PyObject *self, PyObject *args) {
if
(
__Pyx_Generator_CheckExact
(
yf
))
{
if
(
__Pyx_Generator_CheckExact
(
yf
))
{
ret
=
__Pyx_Generator_Throw
(
yf
,
args
);
ret
=
__Pyx_Generator_Throw
(
yf
,
args
);
}
else
{
}
else
{
PyObject
*
meth
=
PyObject_GetAttr
String
(
yf
,
"throw"
);
PyObject
*
meth
=
PyObject_GetAttr
(
yf
,
PYIDENT
(
"throw"
)
);
if
(
unlikely
(
!
meth
))
{
if
(
unlikely
(
!
meth
))
{
Py_DECREF
(
yf
);
Py_DECREF
(
yf
);
if
(
!
PyErr_ExceptionMatches
(
PyExc_AttributeError
))
{
if
(
!
PyErr_ExceptionMatches
(
PyExc_AttributeError
))
{
...
...
Cython/Utility/ObjectHandling.c
View file @
d1e5d1f6
...
@@ -400,7 +400,7 @@ static PyObject *__Pyx_FindPy2Metaclass(PyObject *bases) {
...
@@ -400,7 +400,7 @@ static PyObject *__Pyx_FindPy2Metaclass(PyObject *bases) {
#if PY_MAJOR_VERSION < 3
#if PY_MAJOR_VERSION < 3
if
(
PyTuple_Check
(
bases
)
&&
PyTuple_GET_SIZE
(
bases
)
>
0
)
{
if
(
PyTuple_Check
(
bases
)
&&
PyTuple_GET_SIZE
(
bases
)
>
0
)
{
PyObject
*
base
=
PyTuple_GET_ITEM
(
bases
,
0
);
PyObject
*
base
=
PyTuple_GET_ITEM
(
bases
,
0
);
metaclass
=
PyObject_GetAttr
String
(
base
,
(
char
*
)
"__class__"
);
metaclass
=
PyObject_GetAttr
(
base
,
PYIDENT
(
"__class__"
)
);
if
(
!
metaclass
)
{
if
(
!
metaclass
)
{
PyErr_Clear
();
PyErr_Clear
();
metaclass
=
(
PyObject
*
)
Py_TYPE
(
base
);
metaclass
=
(
PyObject
*
)
Py_TYPE
(
base
);
...
@@ -428,10 +428,10 @@ static PyObject *__Pyx_Py3MetaclassGet(PyObject *bases, PyObject *mkw); /*proto*
...
@@ -428,10 +428,10 @@ static PyObject *__Pyx_Py3MetaclassGet(PyObject *bases, PyObject *mkw); /*proto*
//@requires: FindPy2Metaclass
//@requires: FindPy2Metaclass
static
PyObject
*
__Pyx_Py3MetaclassGet
(
PyObject
*
bases
,
PyObject
*
mkw
)
{
static
PyObject
*
__Pyx_Py3MetaclassGet
(
PyObject
*
bases
,
PyObject
*
mkw
)
{
PyObject
*
metaclass
=
PyDict_GetItem
String
(
mkw
,
"metaclass"
);
PyObject
*
metaclass
=
PyDict_GetItem
(
mkw
,
PYIDENT
(
"metaclass"
)
);
if
(
metaclass
)
{
if
(
metaclass
)
{
Py_INCREF
(
metaclass
);
Py_INCREF
(
metaclass
);
if
(
PyDict_DelItem
String
(
mkw
,
"metaclass"
)
<
0
)
{
if
(
PyDict_DelItem
(
mkw
,
PYIDENT
(
"metaclass"
)
)
<
0
)
{
Py_DECREF
(
metaclass
);
Py_DECREF
(
metaclass
);
return
NULL
;
return
NULL
;
}
}
...
@@ -453,13 +453,13 @@ static PyObject *__Pyx_CreateClass(PyObject *bases, PyObject *dict, PyObject *na
...
@@ -453,13 +453,13 @@ static PyObject *__Pyx_CreateClass(PyObject *bases, PyObject *dict, PyObject *na
PyObject
*
result
;
PyObject
*
result
;
PyObject
*
metaclass
;
PyObject
*
metaclass
;
if
(
PyDict_SetItem
String
(
dict
,
"__module__"
,
modname
)
<
0
)
if
(
PyDict_SetItem
(
dict
,
PYIDENT
(
"__module__"
)
,
modname
)
<
0
)
return
NULL
;
return
NULL
;
if
(
PyDict_SetItem
String
(
dict
,
"__qualname__"
,
qualname
)
<
0
)
if
(
PyDict_SetItem
(
dict
,
PYIDENT
(
"__qualname__"
)
,
qualname
)
<
0
)
return
NULL
;
return
NULL
;
/* Python2 __metaclass__ */
/* Python2 __metaclass__ */
metaclass
=
PyDict_GetItem
String
(
dict
,
"__metaclass__"
);
metaclass
=
PyDict_GetItem
(
dict
,
PYIDENT
(
"__metaclass__"
)
);
if
(
metaclass
)
{
if
(
metaclass
)
{
Py_INCREF
(
metaclass
);
Py_INCREF
(
metaclass
);
}
else
{
}
else
{
...
@@ -484,7 +484,7 @@ static PyObject *__Pyx_Py3MetaclassPrepare(PyObject *metaclass, PyObject *bases,
...
@@ -484,7 +484,7 @@ static PyObject *__Pyx_Py3MetaclassPrepare(PyObject *metaclass, PyObject *bases,
PyObject
*
ns
;
PyObject
*
ns
;
PyObject
*
str
;
PyObject
*
str
;
prep
=
PyObject_GetAttr
String
(
metaclass
,
(
char
*
)
"__prepare__"
);
prep
=
PyObject_GetAttr
(
metaclass
,
PYIDENT
(
"__prepare__"
)
);
if
(
!
prep
)
{
if
(
!
prep
)
{
if
(
!
PyErr_ExceptionMatches
(
PyExc_AttributeError
))
if
(
!
PyErr_ExceptionMatches
(
PyExc_AttributeError
))
return
NULL
;
return
NULL
;
...
...
Cython/Utility/Optimize.c
View file @
d1e5d1f6
...
@@ -39,6 +39,10 @@ static CYTHON_INLINE int __Pyx_PyList_Append(PyObject* list, PyObject* x) {
...
@@ -39,6 +39,10 @@ static CYTHON_INLINE int __Pyx_PyList_Append(PyObject* list, PyObject* x) {
/////////////// pop.proto ///////////////
/////////////// pop.proto ///////////////
static
CYTHON_INLINE
PyObject
*
__Pyx_PyObject_Pop
(
PyObject
*
L
);
/*proto*/
/////////////// pop ///////////////
static
CYTHON_INLINE
PyObject
*
__Pyx_PyObject_Pop
(
PyObject
*
L
)
{
static
CYTHON_INLINE
PyObject
*
__Pyx_PyObject_Pop
(
PyObject
*
L
)
{
#if CYTHON_COMPILING_IN_CPYTHON && PY_VERSION_HEX >= 0x02040000
#if CYTHON_COMPILING_IN_CPYTHON && PY_VERSION_HEX >= 0x02040000
if
(
likely
(
PyList_CheckExact
(
L
))
if
(
likely
(
PyList_CheckExact
(
L
))
...
@@ -53,12 +57,16 @@ static CYTHON_INLINE PyObject* __Pyx_PyObject_Pop(PyObject* L) {
...
@@ -53,12 +57,16 @@ static CYTHON_INLINE PyObject* __Pyx_PyObject_Pop(PyObject* L) {
}
}
#endif
#endif
#endif
#endif
return
PyObject_CallMethod
(
L
,
(
char
*
)
"pop"
,
NULL
);
return
PyObject_CallMethod
ObjArgs
(
L
,
PYIDENT
(
"pop"
)
,
NULL
);
}
}
/////////////// pop_index.proto ///////////////
/////////////// pop_index.proto ///////////////
static
PyObject
*
__Pyx_PyObject_PopIndex
(
PyObject
*
L
,
Py_ssize_t
ix
);
/*proto*/
/////////////// pop_index ///////////////
static
PyObject
*
__Pyx_PyObject_PopIndex
(
PyObject
*
L
,
Py_ssize_t
ix
)
{
static
PyObject
*
__Pyx_PyObject_PopIndex
(
PyObject
*
L
,
Py_ssize_t
ix
)
{
PyObject
*
r
,
*
m
,
*
t
,
*
py_ix
;
PyObject
*
r
,
*
m
,
*
t
,
*
py_ix
;
#if CYTHON_COMPILING_IN_CPYTHON && PY_VERSION_HEX >= 0x02040000
#if CYTHON_COMPILING_IN_CPYTHON && PY_VERSION_HEX >= 0x02040000
...
@@ -79,7 +87,7 @@ static PyObject* __Pyx_PyObject_PopIndex(PyObject* L, Py_ssize_t ix) {
...
@@ -79,7 +87,7 @@ static PyObject* __Pyx_PyObject_PopIndex(PyObject* L, Py_ssize_t ix) {
}
}
#endif
#endif
py_ix
=
t
=
NULL
;
py_ix
=
t
=
NULL
;
m
=
__Pyx_GetAttrString
(
L
,
"pop"
);
m
=
PyObject_GetAttr
(
L
,
PYIDENT
(
"pop"
)
);
if
(
!
m
)
goto
bad
;
if
(
!
m
)
goto
bad
;
py_ix
=
PyInt_FromSsize_t
(
ix
);
py_ix
=
PyInt_FromSsize_t
(
ix
);
if
(
!
py_ix
)
goto
bad
;
if
(
!
py_ix
)
goto
bad
;
...
@@ -258,6 +266,10 @@ static CYTHON_INLINE char __Pyx_PyBytes_GetItemInt(PyObject* bytes, Py_ssize_t i
...
@@ -258,6 +266,10 @@ static CYTHON_INLINE char __Pyx_PyBytes_GetItemInt(PyObject* bytes, Py_ssize_t i
/////////////// dict_getitem_default.proto ///////////////
/////////////// dict_getitem_default.proto ///////////////
static
PyObject
*
__Pyx_PyDict_GetItemDefault
(
PyObject
*
d
,
PyObject
*
key
,
PyObject
*
default_value
);
/*proto*/
/////////////// dict_getitem_default ///////////////
static
PyObject
*
__Pyx_PyDict_GetItemDefault
(
PyObject
*
d
,
PyObject
*
key
,
PyObject
*
default_value
)
{
static
PyObject
*
__Pyx_PyDict_GetItemDefault
(
PyObject
*
d
,
PyObject
*
key
,
PyObject
*
default_value
)
{
PyObject
*
value
;
PyObject
*
value
;
#if PY_MAJOR_VERSION >= 3
#if PY_MAJOR_VERSION >= 3
...
@@ -278,7 +290,7 @@ static PyObject* __Pyx_PyDict_GetItemDefault(PyObject* d, PyObject* key, PyObjec
...
@@ -278,7 +290,7 @@ static PyObject* __Pyx_PyDict_GetItemDefault(PyObject* d, PyObject* key, PyObjec
Py_INCREF
(
value
);
Py_INCREF
(
value
);
}
else
{
}
else
{
PyObject
*
m
;
PyObject
*
m
;
m
=
__Pyx_GetAttrString
(
d
,
"get"
);
m
=
PyObject_GetAttr
(
d
,
PYIDENT
(
"get"
)
);
if
(
!
m
)
return
NULL
;
if
(
!
m
)
return
NULL
;
value
=
PyObject_CallFunctionObjArgs
(
m
,
key
,
value
=
PyObject_CallFunctionObjArgs
(
m
,
key
,
(
default_value
==
Py_None
)
?
NULL
:
default_value
,
NULL
);
(
default_value
==
Py_None
)
?
NULL
:
default_value
,
NULL
);
...
@@ -291,6 +303,10 @@ static PyObject* __Pyx_PyDict_GetItemDefault(PyObject* d, PyObject* key, PyObjec
...
@@ -291,6 +303,10 @@ static PyObject* __Pyx_PyDict_GetItemDefault(PyObject* d, PyObject* key, PyObjec
/////////////// dict_setdefault.proto ///////////////
/////////////// dict_setdefault.proto ///////////////
static
PyObject
*
__Pyx_PyDict_SetDefault
(
PyObject
*
d
,
PyObject
*
key
,
PyObject
*
default_value
);
/*proto*/
/////////////// dict_setdefault ///////////////
static
PyObject
*
__Pyx_PyDict_SetDefault
(
PyObject
*
d
,
PyObject
*
key
,
PyObject
*
default_value
)
{
static
PyObject
*
__Pyx_PyDict_SetDefault
(
PyObject
*
d
,
PyObject
*
key
,
PyObject
*
default_value
)
{
PyObject
*
value
;
PyObject
*
value
;
#if PY_MAJOR_VERSION >= 3
#if PY_MAJOR_VERSION >= 3
...
@@ -315,7 +331,7 @@ static PyObject *__Pyx_PyDict_SetDefault(PyObject *d, PyObject *key, PyObject *d
...
@@ -315,7 +331,7 @@ static PyObject *__Pyx_PyDict_SetDefault(PyObject *d, PyObject *key, PyObject *d
Py_INCREF
(
value
);
Py_INCREF
(
value
);
}
else
{
}
else
{
PyObject
*
m
;
PyObject
*
m
;
m
=
__Pyx_GetAttrString
(
d
,
"setdefault"
);
m
=
PyObject_GetAttr
(
d
,
PYIDENT
(
"setdefault"
)
);
if
(
!
m
)
return
NULL
;
if
(
!
m
)
return
NULL
;
value
=
PyObject_CallFunctionObjArgs
(
m
,
key
,
default_value
,
NULL
);
value
=
PyObject_CallFunctionObjArgs
(
m
,
key
,
default_value
,
NULL
);
Py_DECREF
(
m
);
Py_DECREF
(
m
);
...
...
Cython/Utility/Printing.c
View file @
d1e5d1f6
...
@@ -72,7 +72,7 @@ static int __Pyx_Print(PyObject* stream, PyObject *arg_tuple, int newline) {
...
@@ -72,7 +72,7 @@ static int __Pyx_Print(PyObject* stream, PyObject *arg_tuple, int newline) {
PyObject
*
result
=
0
;
PyObject
*
result
=
0
;
PyObject
*
end_string
;
PyObject
*
end_string
;
if
(
unlikely
(
!
$
print_function
))
{
if
(
unlikely
(
!
$
print_function
))
{
$
print_function
=
__Pyx_GetAttrString
(
$
builtins_cname
,
"print"
);
$
print_function
=
PyObject_GetAttr
(
$
builtins_cname
,
PYIDENT
(
"print"
)
);
if
(
!
$
print_function
)
if
(
!
$
print_function
)
return
-
1
;
return
-
1
;
}
}
...
@@ -80,13 +80,13 @@ static int __Pyx_Print(PyObject* stream, PyObject *arg_tuple, int newline) {
...
@@ -80,13 +80,13 @@ static int __Pyx_Print(PyObject* stream, PyObject *arg_tuple, int newline) {
kwargs
=
PyDict_New
();
kwargs
=
PyDict_New
();
if
(
unlikely
(
!
kwargs
))
if
(
unlikely
(
!
kwargs
))
return
-
1
;
return
-
1
;
if
(
unlikely
(
PyDict_SetItem
String
(
kwargs
,
"file"
,
stream
)
<
0
))
if
(
unlikely
(
PyDict_SetItem
(
kwargs
,
PYIDENT
(
"file"
)
,
stream
)
<
0
))
goto
bad
;
goto
bad
;
if
(
!
newline
)
{
if
(
!
newline
)
{
end_string
=
PyUnicode_FromStringAndSize
(
" "
,
1
);
end_string
=
PyUnicode_FromStringAndSize
(
" "
,
1
);
if
(
unlikely
(
!
end_string
))
if
(
unlikely
(
!
end_string
))
goto
bad
;
goto
bad
;
if
(
PyDict_SetItem
String
(
kwargs
,
"end"
,
end_string
)
<
0
)
{
if
(
PyDict_SetItem
(
kwargs
,
PYIDENT
(
"end"
)
,
end_string
)
<
0
)
{
Py_DECREF
(
end_string
);
Py_DECREF
(
end_string
);
goto
bad
;
goto
bad
;
}
}
...
@@ -100,7 +100,7 @@ static int __Pyx_Print(PyObject* stream, PyObject *arg_tuple, int newline) {
...
@@ -100,7 +100,7 @@ static int __Pyx_Print(PyObject* stream, PyObject *arg_tuple, int newline) {
end_string
=
PyUnicode_FromStringAndSize
(
" "
,
1
);
end_string
=
PyUnicode_FromStringAndSize
(
" "
,
1
);
if
(
unlikely
(
!
end_string
))
if
(
unlikely
(
!
end_string
))
return
-
1
;
return
-
1
;
if
(
PyDict_SetItem
String
(
$
print_function_kwargs
,
"end"
,
end_string
)
<
0
)
{
if
(
PyDict_SetItem
(
$
print_function_kwargs
,
PYIDENT
(
"end"
)
,
end_string
)
<
0
)
{
Py_DECREF
(
end_string
);
Py_DECREF
(
end_string
);
return
-
1
;
return
-
1
;
}
}
...
...
Cython/Utility/TypeConversion.c
View file @
d1e5d1f6
...
@@ -130,7 +130,7 @@ static {{struct_type_decl}} {{funcname}}(PyObject * o) {
...
@@ -130,7 +130,7 @@ static {{struct_type_decl}} {{funcname}}(PyObject * o) {
{{
for
member
in
var_entries
:
}}
{{
for
member
in
var_entries
:
}}
{{
py
:
attr
=
"result."
+
member
.
cname
}}
{{
py
:
attr
=
"result."
+
member
.
cname
}}
value
=
Py
Mapping_GetItemString
(
o
,
(
char
*
)
"{{member.name}}"
);
value
=
Py
Object_GetItem
(
o
,
PYIDENT
(
"{{member.name}}"
)
);
if
(
!
value
)
{
if
(
!
value
)
{
PyErr_SetString
(
PyExc_ValueError
,
"No value specified for struct "
PyErr_SetString
(
PyExc_ValueError
,
"No value specified for struct "
"attribute '{{member.name}}'"
);
"attribute '{{member.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