Hi, On 2013-02-18, Nils Bruin <nbr...@sfu.ca> wrote: > sage: cython("""cdef class Foo(object): ...""") > sage: provide_hash_by_id(Foo)
That would indeed be the plan for the less intrusive version, but... > If we can't resolve why setting "tp_hash" manually is different from > providing a "def __hash__" then indeed, it is necessary, because > inheritance of the hash is the whole point. And then avoiding an extra > (cython) class at the expense of a `__classcall__` sounds attractive, > given how `UniqueRepresentation` already has to play tricks with that. > However, if we can resolve this by simply ensuring that some static > data structure holds the desired values, I think the flexibility would > be worth it. > >> But intrusive would be both, as I've shown above! > > I doubt it would be if we don't scribble in the type of the > instantiated object (which would be the subclass!), but instead update > the data structure right at the start. *If* possible. I don't see what I did wrong here, but when I assign to the tp_hash of Foo (before or after creating instances) and then create a sub-class, the sub-class forgets everything about the hash. Which might actually be what we want, because then it is using the hash of <object>... Cheers, Simon -- You received this message because you are subscribed to the Google Groups "sage-devel" group. To unsubscribe from this group and stop receiving emails from it, send an email to sage-devel+unsubscr...@googlegroups.com. To post to this group, send email to sage-devel@googlegroups.com. Visit this group at http://groups.google.com/group/sage-devel?hl=en. For more options, visit https://groups.google.com/groups/opt_out.