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
108ab86b
Commit
108ab86b
authored
Oct 20, 2011
by
Robert Bradshaw
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Move list_pop to external utility code.
parent
af273350
Changes
2
Show whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
52 additions
and
51 deletions
+52
-51
Cython/Compiler/Optimize.py
Cython/Compiler/Optimize.py
+5
-51
Cython/Utility/Optimize.c
Cython/Utility/Optimize.c
+47
-0
No files found.
Cython/Compiler/Optimize.py
View file @
108ab86b
...
@@ -15,7 +15,7 @@ import Symtab
...
@@ -15,7 +15,7 @@ import Symtab
import
Options
import
Options
import
Naming
import
Naming
from
Code
import
UtilityCode
from
Code
import
UtilityCode
,
ContentHashingUtilityCode
from
StringEncoding
import
EncodedString
,
BytesLiteral
from
StringEncoding
import
EncodedString
,
BytesLiteral
from
Errors
import
error
from
Errors
import
error
from
ParseTreeTransforms
import
SkipDeclarations
from
ParseTreeTransforms
import
SkipDeclarations
...
@@ -32,6 +32,9 @@ try:
...
@@ -32,6 +32,9 @@ try:
except
ImportError
:
except
ImportError
:
basestring
=
str
# Python 3
basestring
=
str
# Python 3
def
load_c_utility
(
name
):
return
ContentHashingUtilityCode
.
load
(
name
,
"Optimize.c"
)
class
FakePythonEnv
(
object
):
class
FakePythonEnv
(
object
):
"A fake environment for creating type test nodes etc."
"A fake environment for creating type test nodes etc."
nogil
=
False
nogil
=
False
...
@@ -2321,7 +2324,7 @@ class OptimizeBuiltinCalls(Visitor.EnvTransform):
...
@@ -2321,7 +2324,7 @@ class OptimizeBuiltinCalls(Visitor.EnvTransform):
args
=
args
,
args
=
args
,
may_return_none
=
True
,
may_return_none
=
True
,
is_temp
=
node
.
is_temp
,
is_temp
=
node
.
is_temp
,
utility_code
=
pop_index_utility_code
utility_code
=
load_c_utility
(
"pop_index"
)
)
)
return
node
return
node
...
@@ -3214,55 +3217,6 @@ static CYTHON_INLINE PyObject* __Pyx_PyObject_Pop(PyObject* L) {
...
@@ -3214,55 +3217,6 @@ static CYTHON_INLINE PyObject* __Pyx_PyObject_Pop(PyObject* L) {
impl
=
""
impl
=
""
)
)
pop_index_utility_code
=
UtilityCode
(
proto
=
"""
static PyObject* __Pyx_PyObject_PopIndex(PyObject* L, Py_ssize_t ix);
"""
,
impl
=
"""
static PyObject* __Pyx_PyObject_PopIndex(PyObject* L, Py_ssize_t ix) {
PyObject *r, *m, *t, *py_ix;
#if PY_VERSION_HEX >= 0x02040000
if (likely(PyList_CheckExact(L))) {
Py_ssize_t size = PyList_GET_SIZE(L);
if (likely(size > (((PyListObject*)L)->allocated >> 1))) {
if (ix < 0) {
ix += size;
}
if (likely(0 <= ix && ix < size)) {
Py_ssize_t i;
PyObject* v = PyList_GET_ITEM(L, ix);
Py_SIZE(L) -= 1;
size -= 1;
for(i=ix; i<size; i++) {
PyList_SET_ITEM(L, i, PyList_GET_ITEM(L, i+1));
}
return v;
}
}
}
#endif
py_ix = t = NULL;
m = __Pyx_GetAttrString(L, "pop");
if (!m) goto bad;
py_ix = PyInt_FromSsize_t(ix);
if (!py_ix) goto bad;
t = PyTuple_New(1);
if (!t) goto bad;
PyTuple_SET_ITEM(t, 0, py_ix);
py_ix = NULL;
r = PyObject_CallObject(m, t);
Py_DECREF(m);
Py_DECREF(t);
return r;
bad:
Py_XDECREF(m);
Py_XDECREF(t);
Py_XDECREF(py_ix);
return NULL;
}
"""
)
py_dict_clear_utility_code
=
UtilityCode
(
py_dict_clear_utility_code
=
UtilityCode
(
proto
=
'''
proto
=
'''
...
...
Cython/Utility/Optimize.c
0 → 100644
View file @
108ab86b
/////////////// pop_index.proto ///////////////
static
PyObject
*
__Pyx_PyObject_PopIndex
(
PyObject
*
L
,
Py_ssize_t
ix
);
/////////////// pop_index.proto ///////////////
static
PyObject
*
__Pyx_PyObject_PopIndex
(
PyObject
*
L
,
Py_ssize_t
ix
)
{
PyObject
*
r
,
*
m
,
*
t
,
*
py_ix
;
#if PY_VERSION_HEX >= 0x02040000
if
(
likely
(
PyList_CheckExact
(
L
)))
{
Py_ssize_t
size
=
PyList_GET_SIZE
(
L
);
if
(
likely
(
size
>
(((
PyListObject
*
)
L
)
->
allocated
>>
1
)))
{
if
(
ix
<
0
)
{
ix
+=
size
;
}
if
(
likely
(
0
<=
ix
&&
ix
<
size
))
{
Py_ssize_t
i
;
PyObject
*
v
=
PyList_GET_ITEM
(
L
,
ix
);
Py_SIZE
(
L
)
-=
1
;
size
-=
1
;
for
(
i
=
ix
;
i
<
size
;
i
++
)
{
PyList_SET_ITEM
(
L
,
i
,
PyList_GET_ITEM
(
L
,
i
+
1
));
}
return
v
;
}
}
}
#endif
py_ix
=
t
=
NULL
;
m
=
__Pyx_GetAttrString
(
L
,
"pop"
);
if
(
!
m
)
goto
bad
;
py_ix
=
PyInt_FromSsize_t
(
ix
);
if
(
!
py_ix
)
goto
bad
;
t
=
PyTuple_New
(
1
);
if
(
!
t
)
goto
bad
;
PyTuple_SET_ITEM
(
t
,
0
,
py_ix
);
py_ix
=
NULL
;
r
=
PyObject_CallObject
(
m
,
t
);
Py_DECREF
(
m
);
Py_DECREF
(
t
);
return
r
;
bad:
Py_XDECREF
(
m
);
Py_XDECREF
(
t
);
Py_XDECREF
(
py_ix
);
return
NULL
;
}
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