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
fc193531
Commit
fc193531
authored
Mar 16, 2013
by
Stefan Behnel
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
avoid code duplication by generating List/Tuple_GetSlice utility code from a common template
parent
ce58dc06
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
10 additions
and
26 deletions
+10
-26
Cython/Compiler/ExprNodes.py
Cython/Compiler/ExprNodes.py
+2
-2
Cython/Utility/ObjectHandling.c
Cython/Utility/ObjectHandling.c
+8
-24
No files found.
Cython/Compiler/ExprNodes.py
View file @
fc193531
...
...
@@ -3688,11 +3688,11 @@ class SliceIndexNode(ExprNode):
else
:
if
self
.
base
.
type
is
list_type
:
code
.
globalstate
.
use_utility_code
(
UtilityCode
.
load_cached
(
"SliceTupleAndList"
,
"ObjectHandling.c"
))
Tempita
UtilityCode
.
load_cached
(
"SliceTupleAndList"
,
"ObjectHandling.c"
))
cfunc
=
'__Pyx_PyList_GetSlice'
elif
self
.
base
.
type
is
tuple_type
:
code
.
globalstate
.
use_utility_code
(
UtilityCode
.
load_cached
(
"SliceTupleAndList"
,
"ObjectHandling.c"
))
Tempita
UtilityCode
.
load_cached
(
"SliceTupleAndList"
,
"ObjectHandling.c"
))
cfunc
=
'__Pyx_PyTuple_GetSlice'
else
:
cfunc
=
'__Pyx_PySequence_GetSlice'
...
...
Cython/Utility/ObjectHandling.c
View file @
fc193531
...
...
@@ -625,41 +625,25 @@ static CYTHON_INLINE void __Pyx_copy_object_array(PyObject** src, PyObject** des
}
}
static
CYTHON_INLINE
PyObject
*
__Pyx_PyList_GetSlice
(
{{
for
type
in
[
'
List
'
,
'
Tuple
'
]}}
static
CYTHON_INLINE
PyObject
*
__Pyx_Py
{{
type
}}
_GetSlice
(
PyObject
*
src
,
Py_ssize_t
start
,
Py_ssize_t
stop
)
{
PyObject
*
dest
;
Py_ssize_t
length
=
Py
List
_GET_SIZE
(
src
);
Py_ssize_t
length
=
Py
{{
type
}}
_GET_SIZE
(
src
);
__Pyx_crop_slice
(
&
start
,
&
stop
,
&
length
);
if
(
unlikely
(
length
<=
0
))
return
Py
List
_New
(
0
);
return
Py
{{
type
}}
_New
(
0
);
dest
=
Py
List
_New
(
length
);
dest
=
Py
{{
type
}}
_New
(
length
);
if
(
unlikely
(
!
dest
))
return
NULL
;
__Pyx_copy_object_array
(
((
PyListObject
*
)
src
)
->
ob_item
+
start
,
((
PyListObject
*
)
dest
)
->
ob_item
,
length
);
return
dest
;
}
static
CYTHON_INLINE
PyObject
*
__Pyx_PyTuple_GetSlice
(
PyObject
*
src
,
Py_ssize_t
start
,
Py_ssize_t
stop
)
{
PyObject
*
dest
;
Py_ssize_t
length
=
PyTuple_GET_SIZE
(
src
);
__Pyx_crop_slice
(
&
start
,
&
stop
,
&
length
);
if
(
unlikely
(
length
<=
0
))
return
PyTuple_New
(
0
);
dest
=
PyTuple_New
(
length
);
if
(
unlikely
(
!
dest
))
return
NULL
;
__Pyx_copy_object_array
(
((
PyTupleObject
*
)
src
)
->
ob_item
+
start
,
((
PyTupleObject
*
)
dest
)
->
ob_item
,
((
Py
{{
type
}}
Object
*
)
src
)
->
ob_item
+
start
,
((
Py
{{
type
}}
Object
*
)
dest
)
->
ob_item
,
length
);
return
dest
;
}
{{
endfor
}}
#endif
/////////////// FindPy2Metaclass.proto ///////////////
...
...
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