[Cython] crash bug for closures on extension type methods

2011-09-26 Thread Stefan Behnel

Hi,

yes, I know - right after a release is the best time to find crash bugs. 
Here is one that I find particularly unpleasant:


http://trac.cython.org/cython_trac/ticket/742

Given that this was broken for basically forever without anyone noticing, 
this won't qualify for an emergency release, but I think we shouldn't wait 
too long with a follow-up release to get this out.


Stefan
___
cython-devel mailing list
cython-devel@python.org
http://mail.python.org/mailman/listinfo/cython-devel


Re: [Cython] adding support for __dict__ in extension types

2011-09-26 Thread Stefan Behnel

Lisandro Dalcin, 28.02.2011 19:45:

On 28 February 2011 15:09, Robert Bradshaw wrote:

On Mon, Feb 28, 2011 at 8:33 AM, Lisandro Dalcin wrote:

Bringing up this old post...

On 21 June 2010 15:41, Robert Bradshaw 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
optimization).


Note there's also the issue of cpdef methods--if the instance has a
__dict__ then a dict lookup must be performed for every method call
(to make sure it's not overridden).


But if the type do have a __dict__, then tp_dictoffset will be filled
(this is in my patch), and cpdef methods should always go the dict
lookup... Am I missing something?

Now that you mention it, my patch should include tests for all this.
I'll work on that.


Has anything come out of this?

I also can't find a ticket for this, although it certainly is a worthy feature.

Stefan
___
cython-devel mailing list
cython-devel@python.org
http://mail.python.org/mailman/listinfo/cython-devel