cprotobuf icon indicating copy to clipboard operation
cprotobuf copied to clipboard

Document how to access internal dict for faster reads

Open Downchuck opened this issue 9 years ago • 3 comments

Currently, todict makes a copy of the full structure. Simply accessing (or documenting) the internal dict is much faster than using setattr/getattr and reflection.

Downchuck avatar Sep 26 '15 18:09 Downchuck

Why not post some code, i'm not sure exactly what you propose. ;D

yihuang avatar Sep 30 '15 03:09 yihuang

This may not even need code; it's simply a documentation note now.

entity.__dict__

is faster, when appropriate, for accessing fields than using setattr/getattr or creating a dictionary through:

entity.todict()

Downchuck avatar Oct 02 '15 16:10 Downchuck

__dict__ is different from todict, you get a object instance for submessage instead of dict.

yihuang avatar Nov 10 '15 00:11 yihuang