Hello, I noticed that there are many places in Sage where x.__class__ is used. In Cython code however, type(x) is much faster since Cython optimizes type(x) but not x.__class__. The latter is simply compiled as getattr(x, "__class__").

Usually, x.__class__ is the same as type(x), but it's the exceptions I'm worried about. Especially in some places, x.__class__ is *assigned* to, which cannot be done with type(x).

So my question is really: are there any easy-to-check conditions under which it's certainly safe to change x.__class__ to type(x)?

At the very minimum, I would like to do this for __new__ calls, in code like

cdef type t = x.__class__
my_new_object = t.__new__(t)

--
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.
For more options, visit https://groups.google.com/d/optout.

Reply via email to