Message182959
Currently a subclass of a PyVarObject (such as 'int') cannot use a non-empty slots, for example:
>>> class L (int):
... __slots__ = ('a', 'b')
...
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
TypeError: nonempty __slots__ not supported for subtype of 'int'
>>>
However, subclasses that don't use __slots__ do have an implicit slot: the __dict__ value. Wouldn't it be possible to use the trick used for tp_dictoffset for slots as well, that is use negative values for the slot offsets and access them from the end of the object?
The major problem with an implementation is that PyMember_GetOne has a 'char*' argument instead of a 'PyObject*' one, but that's easily changed (PyMember_GetOne is currently only called in Object/descrobject.c and that call casts PyObject* to char*. This would be an API change, but AFAIK PyMember_GetOne is not documented at the moment (and changing the argument type would be binary compatible).
I hope to work on a patch in the near future. |
|
Date |
User |
Action |
Args |
2013-02-25 16:24:22 | ronaldoussoren | set | recipients:
+ ronaldoussoren |
2013-02-25 16:24:22 | ronaldoussoren | set | messageid: <1361809462.28.0.456255129432.issue17295@psf.upfronthosting.co.za> |
2013-02-25 16:24:22 | ronaldoussoren | link | issue17295 messages |
2013-02-25 16:24:21 | ronaldoussoren | create | |
|