[Python-3000] Bytes and unicode conversion in C extensions
Nick Coghlan
ncoghlan at gmail.com
Fri Aug 15 11:51:57 CEST 2008
Christian Heimes wrote:
> Jesus Cea wrote:
>> Current pybsddb code don't allow subclassing or adding new attibutes to
>> a given instance. I will (probably) work on this for a future pybsddb
>> version. Pointers to references to do this kind of magic welcomed :-)
>
> For making it subclass-able you have to add Py_TPFLAGS_BASETYPE to the
> type flags. In order to make new attributes possible you either need to
> mess around with tp_dict or tp_dictoffset. Grepping for
> _PyObject_GetDictPtr should give you some hints.
There's no real reason to do the latter though - none of the builtin
Python types permit it since once you make the class subclassable, it's
fairly easy for people to add the facility for themselves (as a standard
Python class, the subclass gets a __dict__ attribute automatically).
Cheers,
Nick.
--
Nick Coghlan | ncoghlan at gmail.com | Brisbane, Australia
---------------------------------------------------------------
http://www.boredomandlaziness.org
More information about the Python-3000
mailing list