Store the class metadata of fields in the class, to improve preformance

Cached data include,
- lookup table between groups and fields of "oneof" fields
- default value creator of each field
- type hint of each field
This commit is contained in:
James Lan
2020-05-14 15:20:23 -07:00
parent de61ddab21
commit 3d001a2a1a
3 changed files with 117 additions and 64 deletions

View File

@@ -1,7 +1,6 @@
# Generated by the protocol buffer compiler. DO NOT EDIT!
# sources: {{ ', '.join(description.files) }}
# plugin: python-betterproto
from dataclasses import dataclass
{% if description.datetime_imports %}
from datetime import {% for i in description.datetime_imports %}{{ i }}{% if not loop.last %}, {% endif %}{% endfor %}
@@ -38,7 +37,7 @@ class {{ enum.py_name }}(betterproto.Enum):
{% endfor %}
{% endif %}
{% for message in description.messages %}
@dataclass
@betterproto.protoclass
class {{ message.py_name }}(betterproto.Message):
{% if message.comment %}
{{ message.comment }}