Re: Basic question about speed/coding style/memory

Discussion in 'Python' started by Andrew Berg, Jul 21, 2012.

  1. Andrew Berg

    Andrew Berg Guest

    On 7/21/2012 2:33 AM, Jan Riechers wrote:
    > Block
    > ...
    > versus this block:
    > ...
    > Now, very briefly, what is the better way to proceed in terms of
    > execution speed, readability, coding style?

    Using if/else is the most readable in the general sense. Using return
    (or break or continue as applicable) in this manner would indicate (at
    least to me) that it's an exceptional or otherwise special case and that
    the function can't do what it's supposed to. In that case, I would try
    to catch an exception rather than use if/else whenever possible. I
    highly doubt there is a significant performance difference between them.
    --
    CPython 3.3.0b1 | Windows NT 6.1.7601.17803
    Andrew Berg, Jul 21, 2012
    #1
    1. Advertising

Want to reply to this thread or ask your own question?

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. calmar
    Replies:
    11
    Views:
    748
    calmar
    Feb 21, 2006
  2. Jan Riechers
    Replies:
    6
    Views:
    169
    88888 Dihedral
    Jul 23, 2012
  3. Jan Riechers
    Replies:
    0
    Views:
    106
    Jan Riechers
    Jul 21, 2012
  4. Chris Angelico
    Replies:
    2
    Views:
    147
    88888 Dihedral
    Jul 23, 2012
  5. Andrew Berg
    Replies:
    0
    Views:
    111
    Andrew Berg
    Jul 21, 2012
Loading...

Share This Page