Hi, I'm looking into how to make use of capnproto within a python application, specifically for best practices for:
1. timedelta and datetime objects 2. python dictionaries/mappings (fixed types for key and value) 3. underscore in field names, in contrast to mixedCase (see also https://github.com/jparyani/pycapnp/issues/119) Based on the documentation and previous discussions here, a schema could be defined as: @0x9d82d0c9ef651a20; using Timedelta = UInt64; # ns beetween to points in time struct Datetime = { timestamp @0 :UInt64; # ns since epoch tzoffset @1 :Int16; # timezone offset in minutes } struct Map(Key, Value) { entries @0 :List(Entry); struct Entry { key @0 :Key; value @1 :Value; } } struct Pythonic { datetime @0 :Datetime; timedelta @1 :Timedelta; mapping @2 :Map(Text, Text); mixedCase @3 :Int16; } In order to get fields of type datetime, timedelta, and dict in python a working solution would be to create dedicated wrapper classes for each schema, which would also map access from mixed_case to mixedCase - this feels horrible. Is there a saner solution? Is it possible to introspect python instances of capnp proto objects to learn that "mapping" is a "Map(Text, Text)" and "datetime" a "Datetime"? That way one wrapper class could be used, which feels a bit less horrible. Given that cython code is generated when importing a capnp schema from python, probably the cleanest solution would be to generate the desired code to begin with. What is the right way to do this? best regards Florian -- Florian Friesdorf <[email protected]> GPG FPR: 7A13 5EEE 1421 9FC2 108D BAAF 38F8 99A3 0C45 F083 -- You received this message because you are subscribed to the Google Groups "Cap'n Proto" group. To unsubscribe from this group and stop receiving emails from it, send an email to [email protected]. Visit this group at https://groups.google.com/group/capnproto.
