Hello !

> How can that be? Isn't generally the test by "==" first checking whether
> the two arguments are identical, before calling `.__eq__`?
>
> If python does not do it automatically, then at least in your example it
> would be good to make g.__eq__ use the "self is other" test, before
> doing anything expensive. Probably the problem would also be solved by
> implementing rich comparison via __richcmp__ (not sure though).

DiGraph comparison is slower than it should be for sure. I already
have plans to change that, even though I fear the messy code as I will
have to deal with the usual multiedges/edge labels/loops subcases (and
their combinations).

I should also add the "self is other" test, but that would not change
this example: the code computes a Hasse Diagram from g, and this
second digraph is used as a parameter of Poset. Thus a comparison will
be necessary anyway (g is not even immutable).

> In any case, if there is a reason to have unique representation, then
> ideally the defining data should be easy to compare. Evidently, a
> dictionary lookup has to be involved for any kind of unique
> represenation.

I agree. I think that I can make DiGraph equality faster [1], but it
will not be magic either. Testing equality of graphs will never be
free, and I do think that there should be a way to not pay it if....
you see no need to.

Nathann

[1] especially in the very very very specific case of the digraphs
used by posets

-- 
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