Skip to content

Commit 427cefc

Browse files
Merge pull request #14 from nickyoung-github/readme
Update README
2 parents 3284ff2 + b515649 commit 427cefc

File tree

2 files changed

+18
-3
lines changed

2 files changed

+18
-3
lines changed

README.md

Lines changed: 17 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,8 @@
77
4. [Supported Types](#Supported-Types)
88
5. [Inheritance](#Inheritance)
99
6. [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.
3334
Note that the typcal python developer experience is now somewhat changed, in that it's necessary to build/install
3435
the 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+
3639
You 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
9398
be 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

98103
Using regular `dataclass` or `BaseModel` as members of classes defined with the pydantic_bind versions is very
99104
inefficient and not recommended.
@@ -139,6 +144,16 @@ A likely future enhancement will be to use [cereal](https://github.com/USCiLab/c
139144
However, 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

144159
Code is generated into a directory structure underneath `<top level>/generated`.

setup.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@
66
long_description = fh.read()
77

88
setup(name="pydantic_bind",
9-
version="1.0.4",
9+
version="1.0.5",
1010
description="C++/pybind generation from Pydantic classes",
1111
author="Nick Young",
1212
license=r"https://www.apache.org/licenses/LICENSE-2.0",

0 commit comments

Comments
 (0)