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
[BUG] Eager copying of struct
even though no mutation occurs
#2416
Comments
This is working as intended per @jpamer |
I don't fully understand what you mean. It's mentioned that:
...but as demonstrated here, a copy is in fact created as demonstrated by the output (even though no mutation occurs):
I say "Mojo enforces COW" and not " |
Citation needed. |
I already gave it:
|
I think you misunderstood what Jack wrote in the blog, he was talking about owned argument and move. fn main():
var a: String = "a"
var b = a # a copy is made here
... |
Bug description
Mojo aims to provide copy-on-write semantics, so programmers do not have to pay a price to reassign data if no mutation occurs. However, in the snippet linked below, even though no mutation is performed, the value of
demo_obj_1
is copied eagerly as demonstrated by the output:This introduces unnecessary run-time costs into the program.
Steps to reproduce
Run this snippet in the playground: https://gist.github.com/modularbot/6aed759930420cd70f38795dbcb874fe
System information
The text was updated successfully, but these errors were encountered: