On Nov 13, 2007 12:32 AM, Joel B. Mohler <[EMAIL PROTECTED]> wrote:
> Questions: Should inheriting __hash__ implementations in a cython class work?
Just a trivial remark, yes, it actually does work as the following
simple example shows:
{{{
%cython
cdef class A:
def __hash__(self):
return 2
cdef class B(A):
pass
}}}
{{{
a = A()
b = B()
}}}
{{{
hash(a)
///
2
}}}
{{{
hash(b)
///
2
}}}
> Would C++/C differences matter (there's a smattering of both in these
> classes)? A patch against 2.8.12 is at
> http://kiwistrawberry.us/research/hash-patch-2_8_12.patch
> if you want to see actual code.
>
> As for the implementation, I'll note that one of my concerns is that I was
> going to have to write really nasty low level code to make this fast, but it
> turns out that my implementation is already faster than the current 2.8.12
> and the code is quite decent (i.e. more pythonic than c-like). Actual speed
> comparisons vary greatly amongst classes, but it's clear that there's more
> optimizations to do around the corners in the poly classes (in particular
> some of the __getitem__ implementations are pretty slow).
By the way, one of the coding sprint projects, led by Willem Jan
Palenstijn (Leiden, NL)
implements modifying doctest so it prints out the time for each block
of tests (both wall
and cpu); this might be useful for testing the impact of your patch, a little...
I don't think he's posting anything yet though.
William
--~--~---------~--~----~------------~-------~--~----~
To post to this group, send email to [email protected]
To unsubscribe from this group, send email to [EMAIL PROTECTED]
For more options, visit this group at http://groups.google.com/group/sage-devel
URLs: http://sage.scipy.org/sage/ and http://modular.math.washington.edu/sage/
-~----------~----~----~----~------~----~------~--~---