epics-base / p4p

Python bindings for the PVAccess network client and server.
BSD 3-Clause "New" or "Revised" License
27 stars 38 forks source link

Value.todict would be useful #15

Closed brunoseivam closed 5 years ago

brunoseivam commented 6 years ago

Currently Value has a tolist method. A similar todict method would be useful for passing the resulting dictionary to a different serializing library.

mdavidsaver commented 6 years ago

I was holding out for OrderedDict(), which is a pain from extension code. I guess this would be changed later

mdavidsaver commented 6 years ago

Also, forgive the late reply. For some reason github didn't Subscribe me to notifications for this issue or the associated PR. I just happened to notice it.

mdavidsaver commented 6 years ago

In occurs to me that P4PValue_toList() could be generalized to take a callable as an optional argument, to be applied recursively to the (sub)lists.

Since this issue was opened, the Value and Type sub-classes in p4p.wrapper are now used everywhere. So some of the work of handling OrderedDict could be done there.

mdavidsaver commented 5 years ago

aa82b578ce7d5c56dfe67a37e3d0ecc7334e2132 allows Value.todict(type=OrderedDict). This is in P4P 3.2.0