creating a copy in pycapnp without knowing the underlying type

15 views
Skip to first unread message

vlo...@gmail.com

unread,
Apr 27, 2020, 4:44:45 PM4/27/20
to Cap'n Proto
Let's say I have some capnp schema.capnp file:

```
struct Foo {
   bar :group {
       someValue @0 :Int64;
   }
}
```

In python I do something like:

```
import capnp
import schema_capnp

fp = open("some_capture.bin")
obj = schema_capnp.Foo.read(fp)
copied_bar = copy(obj.bar) <--- Here
```

I'm trying to figure out how to create the copied_bar object without really having to know what the underlying type is. The specific use-case is I have covariant groups in different structs so it's a little more complex than this simple case. I want to create a copy so that I'm not accidentally modifying the underlying instance (I recognize there's a reader in this case which probably won't allow modifying - I'm talking about the general case).

Thanks,
Vitali

vlo...@gmail.com

unread,
Apr 27, 2020, 4:45:48 PM4/27/20
to Cap'n Proto
NVM. Apparently I'm blind when reading the documentation/looking at the dir() of the message. `.copy()` is the thing.
Reply all
Reply to author
Forward
0 new messages