C-API, tp_dictoffset vs tp_members
doomster at knuut.de
Tue Jul 21 07:16:10 CEST 2009
When would I use PyObject_SetAttrString/tp_dictoffset instead of tp_members?
I have a predefined set of members, some of which are optional. The problem
I had with an embedded dictionary was that I can't see its elements using
"dir()". Now I just converted to using tp_members, and it still seems to
work correctly for the cases I tested. Even better, I can declare the fields
as read-only then and add doc-strings. So, I wonder, what made the original
author use tp_dictoffset instead?
In case you wonder, I'm looking at the Python bindings for GDB, file
gdb/python/python-type.c, struct field_object.
 Yes I could ask them, but I'd like to get an understanding of the pros
More information about the Python-list