Get or set data.table copy semantics
dt_copy_semantics.Rd
These functions control how maybe_copy_dt()
decides whether to
return a data.table
by reference (in place) or by value (as a deep copy).
Usage
dt_copy_semantics()
set_dt_copy_semantics(dt_copy_semantics = c("reference", "value"))
Value
dt_copy_semantics()
returns the current semantics as a string,"reference"
or"value"
.set_dt_copy_semantics()
sets the semantics, returning the previous semantics invisibly.
Details
The copy semantics are stored in the global option
dtlg_dt_copy_semantics
. The option can take two values:
"reference"
(default): inputs are treated with reference semantics.If the input is already a
data.table
, it is returned unchanged and aliases are preserved.If the input is a
data.frame
, it is converted to adata.table
in place viadata.table::setDT()
, mutating the caller’s object.
"value"
: inputs are treated with value semantics.The input is converted to a
data.table
(if necessary) and a deep copy is returned, leaving the original unchanged.