Sharing values by reference between kernels should be opt-in
See original GitHub issueReference sharing isn’t the common case. Most kernels don’t share a process (e.g. JavaScript versus C#) and/or have no values that can helpfully be shared by reference without assuming a specific runtime and language in order to bind data to specific types (e.g. SQL, KQL, HTTP). And even in cases where reference sharing is possible (e.g. between C#, F#, and PowerShell in the default kernel configuration in dotnet-interactive
), if the necessary imports and assembly references aren’t in place ahead of time, then the share will fail.
Sharing by reference is useful for some scenarios though, including certain optimizations (reducing serialization and chattiness) and cases where developers want to use kernels directly in process.
For these reasons, #!share
, #!set
, and other magic commands that dispatch SendValue
and RequestValue
commands should be made to opt into reference sharing, for example by specifying an option like --by-ref
. When this is specified for out-of-proc kernels or kernels that don’t wish to share internal types, the magic command should fail.
Issue Analytics
- State:
- Created 8 months ago
- Reactions:2
- Comments:6 (5 by maintainers)
Top GitHub Comments
I like the idea of a warning/diagnostic in the product to help with the transition 👍
Changing this behavior for
#!share
would most likely be a larger breaking change for more users, and for our samples docs, than is worthwhile.After some time spent working on #2765, it seems to me more prudent to use the shift to the new
#!set
command as an opportunity to fix this there. So#!share
will continue to share by reference by default, with that being disabled when the--mime-type
option is used.#!set
on the other hand will require the use of a--byref
option to perform reference sharing, with the following resulting in an error:--mime-type
and--byref
together.