Skip to content

Use sync iterator in coro-prime-sieve for Dart #285

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

Closed

Conversation

blaugold
Copy link
Contributor

core-prime-sieve/1.dart uses async iteration which has considerable overhead.

@hanabi1224
Copy link
Owner

hanabi1224 commented Jul 18, 2022

Sync generators are not allowed in this problem, plz refer to #279 (comment)

@blaugold
Copy link
Contributor Author

Ah, sorry, got it.

Just as a heads-up: In Dart 2.18.0 the async implementation has been rewritten. The sort of code used in coro-prime-sieve essentially is lowered into synchronous code. This leads to stack-overflows for higher n values (>1000).

One way to fix this is to replace yield i; in filter with yield await Future.microtask(() => i);

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.

2 participants