Hi,

On Mon, Feb 11, 2019 at 11:14:35AM +0100, Jeroen Demeyer wrote:
> On 2019-02-11 11:12, David Coudert wrote:
> > 
> > 
> > Le mardi 29 janvier 2019 23:19:12 UTC+1, Thierry (sage-googlesucks@xxx)
> > a écrit :
[...]
> > 
> >     That said, regarding the .edges() method, i think that returning a list
> >     of pairs is a very wrong approach (though this is what is done for
> >     years). Indeed, a list is not only an iterator, but also a
> >     container. In
> >     particular:
> > 
> >          (a,b) in G.edges()
> > 
> >     is a syntaxially correct statement, but it is far from equivalent to:
> > 
> >          G.has_edge(a,b)
> > 
> >     Which is extremely misleading and can lead to silent mistakes
> >     (personally, i used lot of hand-made reorderings in my pyograms
> >     before i
> >     discovered has_edge).
> > 
> >     Here i would advocate that G.edges() returns a *view* on G, with a
> >     dedicated __iter__ method corresponding to the edge_iterator method and
> >     a __contains__ method corresponding to the has_edge method. By having a
> >     view, you will save a lot of time and memory, and have the benefit that
> >     it will follow the graph's mutations.
> > 
> > 
> > This is an interesting idea, although I'm not sure how to implement that
> > efficiently.
> 
> I don't see why it should be inefficient (assuming you implement it in
> Cython of course).

Actually, a view is somehow pointing to an existing object, so it is
O(1), to be compared to contstructing a list which is O(|E|).

Ciao,
Thierry

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

Reply via email to