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
a78a72f3
Commit
a78a72f3
authored
Apr 15, 2015
by
Chris Toshok
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
zip() takes varargs. django passes 3 containers to it.
parent
3d9ead49
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
29 additions
and
9 deletions
+29
-9
src/runtime/builtin_modules/builtins.cpp
src/runtime/builtin_modules/builtins.cpp
+27
-9
test/tests/builtins.py
test/tests/builtins.py
+2
-0
No files found.
src/runtime/builtin_modules/builtins.cpp
View file @
a78a72f3
...
@@ -554,19 +554,36 @@ Box* filter2(Box* f, Box* container) {
...
@@ -554,19 +554,36 @@ Box* filter2(Box* f, Box* container) {
return
rtn
;
return
rtn
;
}
}
Box
*
zip2
(
Box
*
container1
,
Box
*
container2
)
{
Box
*
zip
(
BoxedTuple
*
containers
)
{
assert
(
containers
->
cls
==
tuple_cls
);
BoxedList
*
rtn
=
new
BoxedList
();
BoxedList
*
rtn
=
new
BoxedList
();
if
(
containers
->
size
()
==
0
)
return
rtn
;
llvm
::
iterator_range
<
BoxIterator
>
range1
=
container1
->
pyElements
();
std
::
vector
<
llvm
::
iterator_range
<
BoxIterator
>>
ranges
;
llvm
::
iterator_range
<
BoxIterator
>
range2
=
container2
->
pyElements
();
for
(
auto
container
:
*
containers
)
{
ranges
.
push_back
(
container
->
pyElements
());
}
BoxIterator
it1
=
range1
.
begin
();
std
::
vector
<
BoxIterator
>
iterators
;
BoxIterator
it2
=
range2
.
begin
();
for
(
auto
range
:
ranges
)
{
iterators
.
push_back
(
range
.
begin
());
}
for
(;
it1
!=
range1
.
end
()
&&
it2
!=
range2
.
end
();
++
it1
,
++
it2
)
{
while
(
true
)
{
listAppendInternal
(
rtn
,
BoxedTuple
::
create
({
*
it1
,
*
it2
}));
for
(
int
i
=
0
;
i
<
iterators
.
size
();
i
++
)
{
if
(
iterators
[
i
]
==
ranges
[
i
].
end
())
return
rtn
;
}
auto
el
=
BoxedTuple
::
create
(
iterators
.
size
());
for
(
int
i
=
0
;
i
<
iterators
.
size
();
i
++
)
{
el
->
elts
[
i
]
=
*
iterators
[
i
];
++
(
iterators
[
i
]);
}
listAppendInternal
(
rtn
,
el
);
}
}
return
rtn
;
}
}
static
Box
*
callable
(
Box
*
obj
)
{
static
Box
*
callable
(
Box
*
obj
)
{
...
@@ -1170,7 +1187,8 @@ void setupBuiltins() {
...
@@ -1170,7 +1187,8 @@ void setupBuiltins() {
{
NULL
}));
{
NULL
}));
builtins_module
->
giveAttr
(
"filter"
,
builtins_module
->
giveAttr
(
"filter"
,
new
BoxedBuiltinFunctionOrMethod
(
boxRTFunction
((
void
*
)
filter2
,
LIST
,
2
),
"filter"
));
new
BoxedBuiltinFunctionOrMethod
(
boxRTFunction
((
void
*
)
filter2
,
LIST
,
2
),
"filter"
));
builtins_module
->
giveAttr
(
"zip"
,
new
BoxedBuiltinFunctionOrMethod
(
boxRTFunction
((
void
*
)
zip2
,
LIST
,
2
),
"zip"
));
builtins_module
->
giveAttr
(
"zip"
,
new
BoxedBuiltinFunctionOrMethod
(
boxRTFunction
((
void
*
)
zip
,
LIST
,
0
,
0
,
true
,
false
),
"zip"
));
builtins_module
->
giveAttr
(
builtins_module
->
giveAttr
(
"dir"
,
new
BoxedBuiltinFunctionOrMethod
(
boxRTFunction
((
void
*
)
dir
,
LIST
,
1
,
1
,
false
,
false
),
"dir"
,
{
NULL
}));
"dir"
,
new
BoxedBuiltinFunctionOrMethod
(
boxRTFunction
((
void
*
)
dir
,
LIST
,
1
,
1
,
false
,
false
),
"dir"
,
{
NULL
}));
builtins_module
->
giveAttr
(
"vars"
,
new
BoxedBuiltinFunctionOrMethod
(
builtins_module
->
giveAttr
(
"vars"
,
new
BoxedBuiltinFunctionOrMethod
(
...
...
test/tests/builtins.py
View file @
a78a72f3
...
@@ -27,7 +27,9 @@ class C(object):
...
@@ -27,7 +27,9 @@ class C(object):
print
sum
([
C
(
1
),
C
(
2
),
C
(
3
)],
C
(
4
)).
n
print
sum
([
C
(
1
),
C
(
2
),
C
(
3
)],
C
(
4
)).
n
print
zip
()
print
zip
([
1
,
2
,
3
,
0
],
[
"one"
,
"two"
,
"three"
])
print
zip
([
1
,
2
,
3
,
0
],
[
"one"
,
"two"
,
"three"
])
print
zip
([
1
,
2
,
3
,
0
],
[
"one"
,
"two"
,
"three"
],
[
"uno"
,
"dos"
,
"tres"
,
"quatro"
])
print
filter
(
lambda
x
:
x
%
2
,
xrange
(
20
))
print
filter
(
lambda
x
:
x
%
2
,
xrange
(
20
))
print
type
(
enumerate
([]))
print
type
(
enumerate
([]))
...
...
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