Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
P
Pyston
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
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Commits
Issue Boards
Open sidebar
Boxiang Sun
Pyston
Commits
dbe3767a
Commit
dbe3767a
authored
Apr 05, 2016
by
Kevin Modzelewski
Browse files
Options
Browse Files
Download
Plain Diff
Merge pull request #1127 from Daetalus/refcouting_nexedi_builtin
add refcouting annotation to zip builtin function
parents
125f19b2
7929c0ad
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
21 additions
and
16 deletions
+21
-16
src/runtime/builtin_modules/builtins.cpp
src/runtime/builtin_modules/builtins.cpp
+21
-16
No files found.
src/runtime/builtin_modules/builtins.cpp
View file @
dbe3767a
...
...
@@ -876,7 +876,6 @@ Box* reduce(Box* f, Box* container, Box* initial) {
// from cpython, bltinmodule.c
PyObject
*
filterstring
(
PyObject
*
func
,
BoxedString
*
strobj
)
{
assert
(
0
&&
"check refcounting"
);
PyObject
*
result
;
Py_ssize_t
i
,
j
;
Py_ssize_t
len
=
PyString_Size
(
strobj
);
...
...
@@ -996,7 +995,6 @@ Fail_1:
}
static
PyObject
*
filterunicode
(
PyObject
*
func
,
PyObject
*
strobj
)
{
assert
(
0
&&
"check refcounting"
);
PyObject
*
result
;
Py_ssize_t
i
,
j
;
Py_ssize_t
len
=
PyUnicode_GetSize
(
strobj
);
...
...
@@ -1102,7 +1100,6 @@ Fail_1:
}
static
PyObject
*
filtertuple
(
PyObject
*
func
,
PyObject
*
tuple
)
{
assert
(
0
&&
"check refcounting"
);
PyObject
*
result
;
Py_ssize_t
i
,
j
;
Py_ssize_t
len
=
PyTuple_Size
(
tuple
);
...
...
@@ -1169,7 +1166,6 @@ Fail_1:
}
Box
*
filter2
(
Box
*
f
,
Box
*
container
)
{
assert
(
0
&&
"check refcounting"
);
// If the filter-function argument is None, filter() works by only returning
// the elements that are truthy. This is equivalent to using the bool() constructor.
// - actually since we call nonzero() afterwards, we could use an ident() function
...
...
@@ -1204,40 +1200,44 @@ Box* filter2(Box* f, Box* container) {
}
Box
*
rtn
=
new
BoxedList
();
AUTO_DECREF
(
rtn
);
for
(
Box
*
e
:
container
->
pyElements
())
{
AUTO_DECREF
(
e
);
Box
*
r
=
runtimeCall
(
f
,
ArgPassSpec
(
1
),
e
,
NULL
,
NULL
,
NULL
,
NULL
);
AUTO_DECREF
(
r
);
bool
b
=
nonzero
(
r
);
if
(
b
)
listAppendInternal
(
rtn
,
e
);
}
return
rtn
;
return
incref
(
rtn
)
;
}
Box
*
zip
(
BoxedTuple
*
containers
)
{
assert
(
0
&&
"check refcounting"
);
assert
(
containers
->
cls
==
tuple_cls
);
BoxedList
*
rtn
=
new
BoxedList
();
AUTO_DECREF
(
rtn
);
if
(
containers
->
size
()
==
0
)
return
rtn
;
return
incref
(
rtn
)
;
std
::
vector
<
BoxIteratorRange
>
ranges
;
for
(
auto
container
:
*
containers
)
{
ranges
.
push_back
(
container
->
pyElements
(
));
ranges
.
push_back
(
std
::
move
(
container
->
pyElements
()
));
}
std
::
vector
<
BoxIterator
>
iterators
;
for
(
auto
&&
range
:
ranges
)
{
iterators
.
push_back
(
range
.
begin
(
));
iterators
.
push_back
(
std
::
move
(
range
.
begin
()
));
}
while
(
true
)
{
for
(
int
i
=
0
;
i
<
iterators
.
size
();
i
++
)
{
if
(
iterators
[
i
]
==
ranges
[
i
].
end
())
return
rtn
;
return
incref
(
rtn
)
;
}
auto
el
=
BoxedTuple
::
create
(
iterators
.
size
());
AUTO_DECREF
(
el
);
for
(
int
i
=
0
;
i
<
iterators
.
size
();
i
++
)
{
el
->
elts
[
i
]
=
*
iterators
[
i
];
++
(
iterators
[
i
]);
...
...
@@ -1786,14 +1786,19 @@ Box* builtinCmp(Box* a, Box* b) {
return
PyInt_FromLong
((
long
)
c
);
}
Box
*
builtinApply
(
Box
*
func
,
Box
*
args
,
Box
*
keywords
)
{
assert
(
0
&&
"check refcounting"
)
;
if
(
!
PyTuple_Check
(
args
))
{
if
(
!
PySequence_Check
(
args
))
raiseExcHelper
(
TypeError
,
"apply() arg 2 expected sequence, found %s"
,
getTypeName
(
args
));
args
=
PySequence_Tuple
(
args
);
Box
*
builtinApply
(
Box
*
func
,
Box
*
_
args
,
Box
*
keywords
)
{
Box
*
args
;
if
(
!
PyTuple_Check
(
_
args
))
{
if
(
!
PySequence_Check
(
_
args
))
raiseExcHelper
(
TypeError
,
"apply() arg 2 expected sequence, found %s"
,
getTypeName
(
_
args
));
args
=
PySequence_Tuple
(
_
args
);
checkAndThrowCAPIException
();
}
else
{
args
=
incref
(
_args
);
}
AUTO_DECREF
(
args
);
if
(
keywords
&&
!
PyDict_Check
(
keywords
))
raiseExcHelper
(
TypeError
,
"apply() arg 3 expected dictionary, found %s"
,
getTypeName
(
keywords
));
return
runtimeCall
(
func
,
ArgPassSpec
(
0
,
0
,
true
,
keywords
!=
NULL
),
args
,
keywords
,
NULL
,
NULL
,
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