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

Construction from generator may iterate a second time #86

Open
yha opened this issue Jun 28, 2022 · 0 comments
Open

Construction from generator may iterate a second time #86

yha opened this issue Jun 28, 2022 · 0 comments

Comments

@yha
Copy link

yha commented Jun 28, 2022

For example, this:

expensive_function(k) = (println(k); k > 2 && error("too large!"))
b = OrderedDict(k => expensive_function(k) for k in 1:3)

prints

1       
2
3
1
2
3
ERROR: too large!

(stack trace omitted)

The constructor shouldn't call my expensive_function again on previous elements.
This seems also to affect some (all?) other structures in DataStructures.jl.

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

No branches or pull requests

1 participant