ENH: Remove deepcopies when slicing cubes and copying coords#37
ENH: Remove deepcopies when slicing cubes and copying coords#37
Conversation
|
@marqh |
|
The current behaviour changes the default behaviour so that indexing returns views always (i.e. switch on/off of this behaviour). That is, here is the API proposed for returning a view or a copy: view_cube = cube[slice] # CUBE/COORD VIEW
copy_cube = cube[slice].copy() # CUBE/COORD COPY |
|
If we don't the ability to switch behaviours and or not change the default behaviour then here are some options: Setting an attribute: (akin to numpy.ndarray.flags) copy_cube = cube[slice] # CUBE/COORD COPY
cube.flags.share_data = True
view_cube = cube[slice] # CUBE/COORD VIEWRetuning a cube that is shareable by some function/method: (perhaps returning a sub-class of Cube) copy_cube = cube[slice] # CUBE/COORD COPY
new_cube = cube.as_shareable() or new_cube = util.as_shareable(cube)
view_cube = new_cube[slice] # CUBE/COORD VIEW |
|
My preference would be for the cleaner approach of changing the behaviour with no switch if we can agree to do this (with obvious changes seen by the user where they assume a copy on slicing). |
|
ping @pp-mo |
75e3aec to
97aad87
Compare
Replacement to SciTools#2261, which points to the dask branch.