multiscale / muscle3

The third major version of the MUltiScale Coupling Library and Environment
Apache License 2.0
25 stars 13 forks source link

Copying Data objects containing a grid does not copy the data #286

Open LourensVeen opened 6 months ago

LourensVeen commented 6 months ago

The documentation for Data::operator=() says that the value will be copied if the argument contains a basic type, and that if it's a list or a dict then this Data object will end up referring to the same one. Like a Python object, which is the intent.

However, the implementation will copy only a pointer if the source MessagePack type is STR, BIN, ARRAY, MAP or EXT, which means that strings, grids and Settings objects will also be referenced rather than copied. This needs to be documented more clearly I think. (It would be the same in Python, except that strings are immutable there.)