Re: C-API, tp_dictoffset vs tp_members

2009-07-26 Thread Martin v. Löwis
> I have a predefined set of members, some of which are optional. Having optional fields is also a good reason. >>> What is the use of T_OBJECT_EX vs T_OBJECT in PyMemberDef then? >> Right - this works for optional objects. However, it can't possibly >> work for any of the other fields. >

Re: C-API, tp_dictoffset vs tp_members

2009-07-26 Thread Ulrich Eckhardt
"Martin v. Löwis" wrote: I have a predefined set of members, some of which are optional. >>> Having optional fields is also a good reason. >> >> What is the use of T_OBJECT_EX vs T_OBJECT in PyMemberDef then? > > Right - this works for optional objects. However, it can't possibly > work for

Re: C-API, tp_dictoffset vs tp_members

2009-07-26 Thread Martin v. Löwis
>>> I have a predefined set of members, some of which are optional. >> Having optional fields is also a good reason. > > What is the use of T_OBJECT_EX vs T_OBJECT in PyMemberDef then? Right - this works for optional objects. However, it can't possibly work for any of the other fields. > I woul

Re: C-API, tp_dictoffset vs tp_members

2009-07-26 Thread Ulrich Eckhardt
"Martin v. Löwis" wrote: >> I have a predefined set of members, some of which are optional. > > Having optional fields is also a good reason. What is the use of T_OBJECT_EX vs T_OBJECT in PyMemberDef then? I would have though that the former describes an optional field, because the behaviour of

Re: C-API, tp_dictoffset vs tp_members

2009-07-26 Thread Martin v. Löwis
> When would I use PyObject_SetAttrString/tp_dictoffset instead of tp_members? When I have a variable list of attributes, and cannot statically know what those attributes might be. > I have a predefined set of members, some of which are optional. Having optional fields is also a good reason. >