Skip to content

Commit

Permalink
Trac #21345: very minor speedup in edge_labels
Browse files Browse the repository at this point in the history
by creating the list directly

URL: https://trac.sagemath.org/21345
Reported by: chapoton
Ticket author(s): Frédéric Chapoton
Reviewer(s): David Coudert
  • Loading branch information
Release Manager authored and vbraun committed Aug 28, 2016
2 parents 69f9933 + c62e295 commit 69cf925
Showing 1 changed file with 2 additions and 5 deletions.
7 changes: 2 additions & 5 deletions src/sage/graphs/generic_graph.py
Original file line number Diff line number Diff line change
Expand Up @@ -10813,7 +10813,7 @@ def edge_label(self, u, v=None):

def edge_labels(self):
"""
Returns a list of edge labels.
Return a list of edge labels.

EXAMPLES::

Expand All @@ -10824,10 +10824,7 @@ def edge_labels(self):
sage: G.edge_labels()
['x', 'z', 'a', 'out']
"""
labels = []
for u,v,l in self.edges():
labels.append(l)
return labels
return [l for _, _, l in self.edge_iterator()]

def remove_multiple_edges(self):
"""
Expand Down

0 comments on commit 69cf925

Please sign in to comment.