do we have any good way to push a dict or dict-lik...
# development
h
do we have any good way to push a dict or dict-like object across the FFI boundary, other than encoding it as a tuple of pairs?
a
what else do you have in mind?
h
I'd like to be able to have a python object returned from the engine just include a dictionary, but I don't think this is safe because dictionaries aren't hashable
and there's no dictionary equivalent of a frozenset
a
we can do what twitter.common.collections does with OrderedSet and just have a frozenset of keys and a dict
but it’s not hard to add a dict to an object returned by the engine just with what we have now
converting to a vector of tuples as we already do is probably hashable
h
hm, I thought that a type we returned from an engine intrinsic had to be marked
@dataclass(frozen=True)
(or otherwise hashable), and that this precluded using a
Dict
as one of the fields, but apparently this works fine?
a
oh, hm
(1) we can override the hash method (I LITERALLY HATE SLACK’S WYSIWYG EDITOR!!!)
(2) we can make the dataclass object actually contain a tuple of tuples, and then convert it into a dict with an @memoized_property
h
so is it actually incorrect for a type returned from an engine intrinsic to have a
Dict
field? I thought that either typechecking or some runtime check would catch this if it wasn't okay, but it seems to work fine
a
can you call hash() on it?
h
nope, dict is unhashable
a
that will lead to an error when externs::identify is called on the object