-
Notifications
You must be signed in to change notification settings - Fork 2
Description
See this recipe to copy data over from src to targ:
src = ... # make source store
targ = ... # make target store
targ.update(src)Note that unless a specialized mechanism is implemented this update will be performed by looping through src.items(), and write all items in targ, regardless of the existence of the key. With many items this can be quite inefficient.
targ could implement a specialized efficient mechanism for the update method, but this would only affect the "writing to targ" part in the general case (if our update method remains insensitive to the particulars of src). Part of the inefficiencies come from iterating through src, so (since targ has control here) we could implement targ.update in such a way that it uses some special features of src to coordinate an efficient copying of data.
In sshdol we have a ssh_files.sync_to method to be able to perform an efficient synching of remote (ssh files) to local files (where the ssh_files instance is made). This is a way to circumvent the fact that to make local_files.update(ssh_files) we'd need to implement a specialized local_files class that knows how ssh_files work. A clean design is not clear here, and may not be worth it just to maintain the update interface, avoiding an extra method name. But a design could be envisioned whereby all base dol Stores have a mechanism that enables coordination between both sides of the update to be implemented.