Lightrooom has been extensively reworked under the hood as far as catalog writes go.
Before: writes just wrote.
Now: All writes are accumulated in a transaction but are not committed (and hence not accessible) until exiting the with-write gate. And,
complete undo info is saved for every write.
So, what I do for effiiciency is either:
1) Make "to-do" functions
2) Save "to-do" info.
Then, call all these "to-do" functions, or process all this saved "to-do" info in a single write-gate, or in a succession of dependent write-gates.
I reworked it so on each operation I build a list on changes for each field of a image then I write all the changes. This way I do not have to read any vaules for lightroom except for the original one, which is ok.
You're welcome Allen.
Another consideration is what level of Undo to offer your plugin users. And unlike the name used in lr-function-context.with... functions, the name used in the catalog with-gates is not just for debug (i.e. it is used in the Undo Menu), so provide good names for the Undo operations for your users.
...In case you hadn't noticed yet... (I hadn't noticed for a fairly long while)