[Cython] adding support for __dict__ in extension types

Lisandro Dalcin dalcinl at gmail.com
Mon Feb 28 17:33:16 CET 2011

Bringing up this old post...

On 21 June 2010 15:41, Robert Bradshaw <robertwb at math.washington.edu> wrote:
> On Jun 17, 2010, at 9:31 AM, Lisandro Dalcin wrote:
>> If we special case a __dict__ attribute in extension types, i.e:
>> cdef class Foo:
>>    cdef dict __dict__
>> and fill type->tp_dictoffset, then we can support __dict__ in
>> extension types.
>> What do you think?
> Sounds like a good idea to me. Note that we check tp_dictoffset for
> fast dispatching for cpdef methods (which would be correct as a dict
> lookup *would* be needed if __dict__ is available).

I still have this patch lying around in my disk. I remember Stefan had
some objections. For example, when the user ask for __dict__, a new
dict is unconditionally created (in CPython, type dict are allocated
on-demand).  I propose to get this patch pushed now, and optimize
later (however, I really don't know how to safely implement this

Lisandro Dalcin
Predio CONICET-Santa Fe
Colectora RN 168 Km 472, Paraje El Pozo
3000 Santa Fe, Argentina
Tel: +54-342-4511594 (ext 1011)
Tel/Fax: +54-342-4511169
-------------- next part --------------
A non-text attachment was scrubbed...
Name: exttypedict.diff
Type: text/x-patch
Size: 7985 bytes
Desc: not available
URL: <http://mail.python.org/pipermail/cython-devel/attachments/20110228/4588f997/attachment.bin>

More information about the cython-devel mailing list