#17385: Cleanup Graph.__init__ and DiGraph.__init__
-------------------------------------+-------------------------------------
       Reporter:  vdelecroix         |        Owner:
           Type:  enhancement        |       Status:  positive_review
       Priority:  major              |    Milestone:  sage-6.5
      Component:  graph theory       |   Resolution:
       Keywords:                     |    Merged in:
        Authors:  Vincent Delecroix  |    Reviewers:  David Coudert
Report Upstream:  N/A                |  Work issues:
         Branch:                     |       Commit:
  u/vdelecroix/17385                 |  3f8a98bc9caa9f64504cf2d85ce4ed39ea7ce12c
   Dependencies:  #17384             |     Stopgaps:
-------------------------------------+-------------------------------------

Comment (by tscrim):

 While that's an improvement, the fastest way is to do `if x:` or `if not
 x:`.
 {{{
 sage: x = True
 sage: %timeit if x is True: pass
 10000000 loops, best of 3: 165 ns per loop
 sage: %timeit if x is False: pass
 10000000 loops, best of 3: 148 ns per loop
 sage: %timeit if x: pass
 10000000 loops, best of 3: 91.9 ns per loop
 sage: %timeit if not x: pass
 10000000 loops, best of 3: 80.1 ns per loop
 sage: x = False
 sage: %timeit if x is True: pass
 10000000 loops, best of 3: 148 ns per loop
 sage: %timeit if x is False: pass
 10000000 loops, best of 3: 165 ns per loop
 sage: %timeit if x: pass
 10000000 loops, best of 3: 79.1 ns per loop
 sage: %timeit if not x: pass
 10000000 loops, best of 3: 91.9 ns per loop
 }}}
 So I'd change things to use that. Plus you can simplify things like:
 {{{#!diff
 +         if ((loops is None or loops is False) and
 -         if (not loops and
 }}}
 (and if statements like that are more common).

--
Ticket URL: <http://trac.sagemath.org/ticket/17385#comment:5>
Sage <http://www.sagemath.org>
Sage: Creating a Viable Open Source Alternative to Magma, Maple, Mathematica, 
and MATLAB

-- 
You received this message because you are subscribed to the Google Groups 
"sage-trac" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to [email protected].
To post to this group, send email to [email protected].
Visit this group at http://groups.google.com/group/sage-trac.
For more options, visit https://groups.google.com/d/optout.

Reply via email to