Hacker News new | ask | show | jobs
by JZL003 912 days ago
Copy on write is really nice, especially when I often face a very very large read-only matrix (200+GB) and want to do some embarrassingly parallel processes on subsets of it. I haven't found a language which makes it as easy, not python (although not unexpected), not Julia even
2 comments

> not python

Pandas has a global option to turn on copy-on-write.

https://pandas.pydata.org/docs/dev/user_guide/copy_on_write....

News to me! Will definitely break some of my current code (chained assignments no longer work), but is probably a more sensible default.

To be default mode in Pandas 3, but seeing as how long it took them to pull the trigger on Pandas 2, that could be a while.

If you haven’t tried Swift, copy-on-write is one of the core tenets of its value types (`struct`s, basically), and it’s almost entirely transparent.
It’s only transparent for types that already implement copy-on-write. For custom types you need to implement it yourself, using reference typed private properties.