Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Support iterator protocol #42

Merged
merged 7 commits into from
Sep 7, 2023
Merged

Support iterator protocol #42

merged 7 commits into from
Sep 7, 2023

Conversation

delta003
Copy link
Member

@delta003 delta003 commented Sep 7, 2023

No description provided.

Comment on lines 224 to 230
if (@typeInfo(returnType) == .ErrorUnion) {
const optional_result = result catch return null;
const non_optional_result = optional_result orelse return null;
return (trampoline.wrap(non_optional_result) catch return null).py;
}
const non_optional_result = result orelse return null;
return (trampoline.wrap(non_optional_result) catch return null).py;
Copy link
Member Author

@delta003 delta003 Sep 7, 2023

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

There is some additional unpacking here cause next can return null as valid - to stop iteration

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think having a separate tp_iternext_internal function that can return errors might be useful?

pydust/src/pytypes.zig Outdated Show resolved Hide resolved
pydust/src/pytypes.zig Outdated Show resolved Hide resolved
pydust/src/pytypes.zig Outdated Show resolved Hide resolved
pydust/src/pytypes.zig Outdated Show resolved Hide resolved
Comment on lines 224 to 230
if (@typeInfo(returnType) == .ErrorUnion) {
const optional_result = result catch return null;
const non_optional_result = optional_result orelse return null;
return (trampoline.wrap(non_optional_result) catch return null).py;
}
const non_optional_result = result orelse return null;
return (trampoline.wrap(non_optional_result) catch return null).py;
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think having a separate tp_iternext_internal function that can return errors might be useful?

@delta003
Copy link
Member Author

delta003 commented Sep 7, 2023

Addressed

example/iterators.zig Outdated Show resolved Hide resolved
@delta003 delta003 merged commit 63eb134 into develop Sep 7, 2023
1 check passed
@delta003 delta003 deleted the mb/iterator branch September 7, 2023 12:13
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants