Closed brunoseivam closed 6 years ago
This certainly does the trick. Rather than PyDict_New()
and separate construction though, it would be simpler to do the equivalent of dict([('a','b')])
. This actually isn't difficult (although it wasn't initial obvious to me). Just call the type object. So something like:
PyObject *list = ...;
PyObject *dict = PyObject_CallFunction(&PyDict_Type, "O", list);
This change, along with adding a case in src/p4p/test/test_value.py should do the trick.
You could add to testSubStruct()
after
I agree with your suggestions, it does look cleaner now. Do you think it would be possible to just call OrderedDict
's constructor, instead?
would be possible to just call OrderedDict's constructor, instead?
Sure. Once you get hold of this type it's simple. I haven't found a concise equivalent for from collections import OrderedDict
from extension code. fyi, I'd like to do something similar w/ logging
.
I'm going to merge now, so this can be a later enhancement.
This might not be the best implementation but it demonstrates what I have in mind for #15