774 . [ Supported Types] ( #Supported-Types )
885 . [ Inheritance] ( #Inheritance )
996 . [ Msgpack] ( #Msgpack )
10- 7 . [ Generated Code] ( #Generated-Code )
10+ 7 . [ Namespaces] ( #Namespaces )
11+ 8 . [ Generated Code] ( #Generated-Code )
1112
1213
1314## Overview
@@ -33,6 +34,8 @@ Protobuf-generated python classes.
3334Note that the typcal python developer experience is now somewhat changed, in that it's necessary to build/install
3435the project. I personally use JetBrains CLion, in place of PyCharm for such projects.
3536
37+ For an example project please see (the rather nascent) [ fin-data-model] ( https://github.com/nickyoung-github/fin-data-model )
38+
3639You can create an instance of the pybind class from your original using ` get_pybind_instance() ` , e.g.,
3740
3841* my_class.py:*
@@ -65,6 +68,8 @@ You can create an instance of the pybind class from your original using `get_pyb
6568 orig = MyClass(my_int=123, my_string="hello")
6669 generated = get_pybind_value(orig)
6770
71+ print(f"my_int: {orig.my_int}, {generated.my_int}")
72+
6873
6974## Why Not Protobufs?
7075
@@ -93,7 +98,7 @@ that access __dict__) less efficient. I've also plumbed the computed fields into
9398be used with [ FastAPI] ( https://fastapi.tiangolo.com ) .
9499
95100` dataclass ` works similarly, adding properties to the dataclass, so that the exisitng get and set functionality works
96- seamless in accessing the generated pybind class (also set via a shimmed ` init ` ).
101+ seamless in accessing the generated pybind class (also set via a shimmed ` __init__ ` ).
97102
98103Using regular ` dataclass ` or ` BaseModel ` as members of classes defined with the pydantic_bind versions is very
99104inefficient and not recommended.
@@ -139,6 +144,16 @@ A likely future enhancement will be to use [cereal](https://github.com/USCiLab/c
139144However, I haven't quite worked out how to do that yet.
140145
141146
147+ ## Namespaces
148+
149+ Currently, the generated C++ code uses a single namespace, corresponding to the top-level package name in python.
150+ I intend to introduce namespaces which match the python package structure. However, there are likely to be some
151+ cmake-related foibles, such as not allowing duplicate module names, even if they are in different packages.
152+
153+ pybind modules are also generated per-module, rather than per-package. This is something I am considering changing,
154+ but again, some cmake gymnastics will be required.
155+
156+
142157## Generated Code
143158
144159Code is generated into a directory structure underneath ` <top level>/generated ` .
0 commit comments